This is a great write up! Thank you for sharing. I do have a question though.
I don’t understand the example about nested objects; why is copy in the end still the same as the original obj? I feel that with the accompanying explanation maybe the snippet is wrong, but I don’t know much about how these details work; would you mind explaining this one a bit further?
letobj={a:1,b:2,c:{a:1}}letcopy={...obj}obj['c']['a']=5// obj is {a:1, b:2, c: 5}// copy is {a:1, b:2, c: {a:1}}
Software dev at Netflix | DC techie | Conference speaker | egghead Instructor | TC39 Educators Committee | Girls Who Code Facilitator | Board game geek | @laurieontech on twitter
This is a great write up! Thank you for sharing. I do have a question though.
I don’t understand the example about nested objects; why is
copy
in the end still the same as the originalobj
? I feel that with the accompanying explanation maybe the snippet is wrong, but I don’t know much about how these details work; would you mind explaining this one a bit further?I wrote out a full explanation and the realized the snippet is indeed wrong! Thanks for catching that.
Thanks for clearing it out!