-
Notifications
You must be signed in to change notification settings - Fork 316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
深拷贝那里有点问题 #21
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
深拷贝那里,不能直接将result赋值为空对象,这样会破坏对象的原型链,而且修改了对象。
可以改成这样:
利用原对象的构造函数生成新对象,然后用for in 循环给对象添加属性。不过这种方式也存在弊端,如果构造函数需要接收参数做计算,就会导致执行时报错。
The text was updated successfully, but these errors were encountered: