Skip to content

Instantly share code, notes, and snippets.

@TastyToast
Created June 25, 2014 23:33
Show Gist options
  • Save TastyToast/fa3876c0a4195ee069f1 to your computer and use it in GitHub Desktop.
Save TastyToast/fa3876c0a4195ee069f1 to your computer and use it in GitHub Desktop.
Create Enum From Object
/**
* Creates and enum from the object based on key values
*
* @param {object} Object
* @return {object} enum from object
*/
function buildEnumFromObject_(obj){
var createdEnum = {};
var i = 0;
for(var key in obj) {
if(!obj.hasOwnProperty(key)){
continue;
}
var keyName = key.toUpperCase().replace
var keyName = key.toUpperCase().replace(/\s+/g, '');
createdEnum[keyName] = i;
i = i + 1;
};
return createdEnum;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment