Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript create json object from array

var array = ['a', 1, 'b', 2, 'c', 3],
    object = {},
    i

for (var i = 0; i < array.length; i += 2) {
    object[array[i]] = array[i + 1];
}

console.log(object);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #create #json #object #array
ADD COMMENT
Topic
Name
3+3 =