Friday, 10 February 2012

List or find out all properties / attributes of a JSON / javascript object


var getKeys = function(obj){
   
var keys = [];
   
for(var key in obj){
      keys
.push(key);
   
}
   
return keys;
}


for e.g. suppose if the object name is options then the code would look like :

   var keys = [];
   
for(var key in options){
      keys
.push(key);
   
}

No comments:

Post a Comment