Converting Object to Array using ES6 features
Use (ES5) Array::map
over the keys
with an arrow function (for short syntax only, not functionality):
let arr = Object.keys(obj).map((k) => obj[k])
True ES6 style would be to write a generator, and convert that iterable into an array:
function* values(obj) { for (let prop of Object.keys(obj)) // own properties, you might use // for (let prop in obj) yield obj[prop];}let arr = Array.from(values(obj));
Regrettably, no object iterator has made it into the ES6 natives.
I like the old school way:
var i=0, arr=[];for (var ob in inputObj) arr[i++]=ob;
Old school wins the jsperf test by a large margin, if not the upvotes. Sometimes new additions are "mis-features."