2 ms·
> you have to do Technically you'd have to do console.log("some label: ", JSON.parse(JSON.stringify(someObj))) > In the second version, if someObj changes
by brundolf 6y ago
> you have to do
Technically you'd have to do
console.log("some label: ", JSON.parse(JSON.stringify(someObj)))
> In the second version, if someObj changes after it was logged, when you'll expand it you'll see the updated value
Yes, this is something to be aware of (and is getting beaten to death throughout this comments section), but if like me you mostly use plain objects in an immutable way, you generally don't have to bother with cloning. Just keep this in the back of your head and know when it won't do what you want in a particular context.
- simlevesque 6y ago> Just keep this in the back of your head I would never debug with that mindstate. I don't trust myself.