I have the following code and need to check if a value exists as an array key.
I can't seem to generate the index of the key even though it does exist, any help would be great.
Code:
var run = { // store the actions to trigger
block : function() {
console.log('Blocking…');
},
warning : function() {
console.log('Warning…');
}
};
console.log( $.inArray( 'warning' , run ) );
As far as I can see, warning exists inside run{} and should return an index of 1.
Why isn't the above doesn't get found (index is returned as -1).
Thanks for reading.
$.inArray()expects the 2nd parameter to be an actual array. Something likevar arr = [1,2,'three', 3.5,4];