I have an Array var cars = [2,3,..] which holds a few integers. I\'ve added a few values to the array, but I now need to send this array to a page via jQuery\'s
var cars = [2,3,..]
Wow, seems it got a lot easier nowadays... 3 ways you can do it:
json = { ...array }; json = Object.assign({}, array); json = array.reduce((json, value, key) => { json[key] = value; return json; }, {});