/ Published in: JavaScript

Returns the key name in mainObject if it's a key, and hasOwnProperty of key (to rule out the prototype object. Then it also checks if the key is listed in an array using a jquery function and also tests if it's null.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
for (var key in mainObject){ if(key && mainObject.hasOwnProperty(key) && ($.inArray(key, testAgainstThisArray) !== -1 ) && mainObject[key] !== null ) { console.log(key); } }
Comments
