Javascript hasOwnProperty does not work under Google Chrome
- by WebRookie
I am currently working with some help and it has been going well, until this incident.
function runCommand(commandString)
{
commands = new Object();
commands.clear = function(){ $('#terminal').html('') }
parameters = commandString.split(" ");
command = parameters.shift();
if( commands.hasOwnProperty(command)){
commandscommand;
}
else
{
$('#terminal').append(command+' command not recognized.'+'');
}
}
The person who was helping me made this function, so I could run the "terminal-like" browsers that I needed to work on.
It works fine when using Firefox, heres an example:
guest@shell:/$ sudo make me sandwich
sudo command not recognized.
guest@shell:/$ clear
*clears*
guest@shell:/$ clear
But under google chrome this happen:
guest@shell:/$ sudo make me sandwich
sudo command not recognized.
guest@shell:/$ clear
clear command not recognized.
I believe that it has something to do with "commands.hasOwnProperty(command)" that is preventing it from working properly.
I am using JQuery the javascript library to build the website, and I need to know how to solve this problem, or an alternative.