-
Notifications
You must be signed in to change notification settings - Fork 0
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
手写深拷贝 #9
Labels
手写系列
各种手写原理
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
浅拷贝
Object.assign(target, source)
...
深拷贝
JSON.stringify(obj) / JSON.parse(str)
, 具体原理参考 JSON-MDN但是该方法也是有局限性:
以下代码会报错:
这里包含循环引用对象,无法实现深拷贝。
MessageChanel
Date, RegExp
此时代码为:
其他方式
参考资料:
The text was updated successfully, but these errors were encountered: