Last active
August 29, 2015 14:04
-
-
Save mim-Armand/f7f1015d040969b52b82 to your computer and use it in GitHub Desktop.
getting an array of Object properties in older Versions of JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.objToArray = function(obj) { | |
var array = []; | |
for (key in obj) { | |
if (obj.hasOwnProperty(key)) array.push(key); | |
} | |
return array; | |
}; | |
alert(Object.objToArray(YourObject)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment