Convert an array to an array of objects
问题 How I can convert an array to an array of JavaScript objects. For example I have an array as data = [ ["fruits","frozen","fresh","rotten"], ["apples",884,494,494], ["oranges",4848,494,4949], ["kiwi",848,33,33] ] I want to convert it to a name value pair. For example, first object in the resulting collection would be {"fruits": "apple", "frozen": 884, "fresh": 494, "rotten": 494} and so on for rest of the data. 回答1: DEMO Using your supplied data: var data = [ ["fruits","frozen","fresh","rotten