I need to create a new object iterating over an array of objects which initially looks like this:
startObj = [{'prop': true}, {'prop': false}];
I would like the result to be:
endObj = {0: true, 1: false}
I was thinking to use $.each but then I don’t know how to proceed from here. Any hints?
$.each([{'prop': true}, {'prop': false}], function (i, o) {
var newObj;
// the new object should look like this
// newObj = {0: true, 1: false}
});
Live example: http://jsfiddle.net/8X48q/