JSFiddle - React, Tailwind, and code Playground
JavaScript
(function () {
'use strict';
var data = [
["fruits","frozen","fresh","rotten"],
["apples",884,494,494],
["oranges",4848,494,4949],
["kiwi",848,33,33]
];
var collection = data.slice(); // make a copy
var keys = collection.shift();
collection = collection.map(function (e) {
var obj = {};
keys.forEach(function (key, i) {
obj[key] = e[i];
});
return obj;
});
document.querySelector('pre')
.textContent = JSON.stringify(collection, null, ' ');
})();