javascript - converting array of array into array of keyvalue pairs -
i want convert array of array array of key-value pairs using javascript or jquery.
i have array of array :
var arrofarr = [[1,'one'],[2,'two'],[3,'three']];
how convert arrofarr array of key-value pairs looks like
[{id:1,text:'one'},{id:2,text:'two'},{id:3,text:'three'}]
var result = []; (var = 0, ilength = arrofarr.length; < ilength; i++) { result.push({ id: arrofarr[i][0], text: arrofarr[i][1] }); } console.log(result);
Comments
Post a Comment