Get first element of an object - Node.js Object

Node.js examples for Object:Property

Description

Get first element of an object

Demo Code

/**//from ww w  .j a  v  a2 s . c  om
 * Get first element of an object
 *
 * Parameters:
 * (object) obj
 * 
 * Returns:
 * (object) first element of the object
 */
function first(obj){
  for(var key in obj){
    return obj[key];
  }
}

Related Tutorials