javascript - How i can can map an large object to an array in es6 -
this question has answer here:
- converting js object array using jquery 17 answers
suppose have large object
var object = { a: 1, b: 2, c: 3, d:4, e:5, f:6, g:7, h:8, i:9, j:10 ...}; var array = [];
output [1,2,3,4,5,6,7,8,9,10...]
how can map object array in es6 ? please me.
you use keys, order them , return value in array.
var object = { a: 1, b: 2, c: 3, d:4, e:5, f:6, g:7, h:8, i:9, j:10}; var array = object.keys(object).sort().map(k => object[k]); console.log(array);
Comments
Post a Comment