If you want to access the first property of an object in Javascript? Using this you can access also other properties by indexes. Be aware tho! Object.keys return order is not guaranteed as per ECMAScript however unofficially it is by all major browsers implementations:
1 2 | var obj = { first: 'someVal' }; obj[Object.keys(obj)[0]]; //returns 'someVal' |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.