4 ms·
Re: caveats, if you want to snapshot something at a point in time but still have it look nice: console.log(JSON.stringify(someObject, null, 2)) Will nicel
by nailer 12y ago
Re: caveats, if you want to snapshot something at a point in time but still have it look nice:
console.log(JSON.stringify(someObject, null, 2))
Will nicely indent it for you.
- cleverjake 12y agotwo things about the `null` - the "replacer" function 1. in IE 8, it will choke. it needs to be a function (hopefully you don't have to care about IE 8, though) 2. in all other JSON.strigifable browsers, you can skip it with a falsey value, which is what the `null` is doing here. As a result, you can also use `0` (e.g. stringinfy(foo, 0, 2)), which I like because I can type it faster