javascript - Get array of object's keys -


i keys of javascript object array, either in jquery or pure javascript.

is there less verbose way this?

var foo = { 'alpha' : 'puffin', 'beta' : 'beagle' }; var keys = []; (var key in foo) {     keys.push(key); } 

var foo = { 'alpha' : 'puffin', 'beta' : 'beagle' }; var keys = object.keys(foo); // ['alpha', 'beta']  // (or maybe other order, keys unordered). 

use object.keys.

this es5 feature. means works in modern browsers will not work in legacy browsers.

the es5-shim has implementation of object.keys can steal


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -