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
The shortest way I know to generate valid json from array of integers is
let json = `[${cars}]`
for more general object/array use JSON.stringify(cars) (for object with circular references use this)
let cars = [1,2,3]; cars.push(4,5,6);
let json = `[${cars}]`;
console.log(json);
console.log(JSON.parse(json)); // json validation