Skip to content

Instantly share code, notes, and snippets.

@ImanMh
Last active August 29, 2015 14:05
Show Gist options
  • Save ImanMh/2d279593ee371b5651a4 to your computer and use it in GitHub Desktop.
Save ImanMh/2d279593ee371b5651a4 to your computer and use it in GitHub Desktop.
converst a javascript object into array, aka pure
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