Return to Snippet

Revision: 48091
at June 23, 2011 15:34 by supermauerbros

Initial Code
for (var key in mainObject){ 
        if(key && mainObject.hasOwnProperty(key) && ($.inArray(key, testAgainstThisArray) !== -1 ) && mainObject[key] !== null ) { 

Initial URL

Initial Description
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.

Initial Title
Iterate through keys in an object literal and return the key name.

Initial Tags

Initial Language