Space in between JSON.stringify output
You can also do like this with replace
console.log(JSON.stringify(products).replace(/},{/g,'}, {'));
// /},{/g means all occurance of },{
This may not be what you want, but if you just want it to look better, I would recommend:
console.log(JSON.stringify(products, null, 2));
which would give you
[
{
"name": "Sample Product Name"
},
{
"name": "Sample Product Name 2"
}
]
In the console. If you really just want a space before commas, you could do:
console.log(JSON.stringify(products).split('},{').join('}, {'));
http://jsfiddle.net/2MeMY/3/