Last active
August 29, 2015 14:05
-
-
Save ImanMh/2d279593ee371b5651a4 to your computer and use it in GitHub Desktop.
converst a javascript object into array, aka pure
This file contains hidden or 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
convertObjectToArray = function (obj, mergedPropName) { | |
var arr = []; | |
for (prop in obj) { | |
if (!obj.hasOwnProperty(prop)) | |
continue; | |
var newObj = obj[prop]; | |
newObj[mergedPropName] = prop; | |
arr.push(newObj); | |
} | |
return arr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment