Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> 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.



> Just keep this in the back of your head

I would never debug with that mindstate. I don't trust myself.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: