Convert array of objects to object of objects
The solution:
var array = [{title: 'hi'}, {title: 'ha'}, {title: 'ho'}];var object = {};var arrayToObject = function(array, object){ array.forEach(function(element, index){ object[index] = element; }) console.log(object);}arrayToObject(array, object);
{title: hi}, {title: ha}, {title: ho}
This is not object of objects. These are just objects.
If what you want is a way to handle each object one by one and insert them into your database you could do something like this.
[{title: hi}, {title: ha}, {title: ho}].forEach(function(obj){ //do something with object});