Thursday, January 16, 2014

grabbing a value off of a JavaScript object by position as if grabbing a value off of a JavaScript array

This trick (as advertised here and doctored up slightly by myself) worked...

var obj = { first: 'someVal' };
alert(obj[Object.keys(obj)[0]]);

 
 

...for grabbing a value off of a JavaScript object by position as if grabbing a value off of a JavaScript array.

No comments:

Post a Comment