The compound array associative array in JS is equivalent to an object. To determine whether a key exists in an array (or whether the object contains a certain attribute), you cannot use ary[key] == undefined because there may be ary = {key:undefined}; the correct method should be:
ary.hasOwnProperty(key); or obj.hasOwnProperty(key);
In addition, when using key-value pair to loop composite arrays or objects, you should use:
for(var key in ary) { document.write(key+" : "+ary[key]); }
The above simple example of JavaScript to determine whether there is a key in an array is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.