show filed of object javascript code example

Example 1: javascript list object properties

var person={"first_name":"Bill","last_name":"Jenner"}
//get the person object properties with:
var keys = Object.keys(person); //keys = ["first_name","last_name"]

Example 2: show filed of object javascript

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

Example 3: show filed of object javascript

var keys = Object.keys(myObject);

Tags:

Misc Example