标签云

微信群

扫码加入我们

WeChat QR Code


I thinks its typescript problem not angular2. correct me if I m wrong

2018年12月17日33分34秒

Do you mean deep copy or shallow copy? stackoverflow.com/questions/184710/…

2018年12月18日33分34秒

SurajRao ok now I am also confused, I just want to reset my object to its default state when my work is done with that object. So to do that, I need to store that default copy, but when I make changes at one place all other copy also gets changed. How to prevent that?

2018年12月18日33分34秒

That means you need a deep copy.Better edit the question

2018年12月18日33分34秒

stackoverflow.com/questions/122102/…

2018年12月17日33分34秒

Do you think including lodash just for this one feature is reasonable? To add 2 numbers would you install math.js? So would you keep adding random third party libraries for every trivial task you run into?

2018年12月18日33分34秒

that's why i have given the second option

2018年12月18日33分34秒

I know but that is wrong sadly.. Please see the documentation: Warning for Deep Clone For deep cloning, we need to use other alternatives because Object.assign() copies property values. If the source value is a reference to an object, it only copies that reference value. developer.mozilla.org/en/docs/Web/JavaScript/Reference/…

2018年12月18日33分34秒