We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
深拷贝那里,不能直接将result赋值为空对象,这样会破坏对象的原型链,而且修改了对象。 可以改成这样:
result = new obj.constructor()
利用原对象的构造函数生成新对象,然后用for in 循环给对象添加属性。不过这种方式也存在弊端,如果构造函数需要接收参数做计算,就会导致执行时报错。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
深拷贝那里,不能直接将result赋值为空对象,这样会破坏对象的原型链,而且修改了对象。
可以改成这样:
利用原对象的构造函数生成新对象,然后用for in 循环给对象添加属性。不过这种方式也存在弊端,如果构造函数需要接收参数做计算,就会导致执行时报错。
The text was updated successfully, but these errors were encountered: