I am trying to see if there is a smaller way of converting an array to an object in es6. ( I do not have to worry about cross-browser )
I currently have:
function (values) // values being an array.
{
let [videos, video_count, page] = values;
let data = { videos, video_count, page };
someFunctions(data);
moreFunctions(data);
}
But I was wondering if it's possible to cut out the first line of the function, let [videos....] part. And somehow inline do the conversion.
I have read through mozilla: Destructuring assignment but I could not see it there. (but I may have understood it wrong) and I am really not clever enough to understand ECMA: ES6 Spec.
I suspect it is not possible and the above is already the simplest I can make it.
But if I can get away with not creating the videos, video_count & page tmp variables I would be happier.
var data = {videos:values[0], video_count:values[1], page:values[2]};