首页
注册
登录
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请
登录
V2EX
›
feipeng
›
全部回复第 1 页 / 共 1 页
回复总数
2
2019-04-01 22:22:00 +08:00
回复了
feipeng
创建的主题
›
jQuery
›
jQuery.extend 在深复制时,为什么需要判断 isPlainOjbect?(不是问 isPlainOjbect 方法的原理)
防止死循环是用[结构化克隆](
https://developer.mozilla.org/zh-CN/docs/Web/Guide/API/DOM/The_structured_clone_algorithm
)
2019-04-01 22:07:23 +08:00
回复了
feipeng
创建的主题
›
jQuery
›
jQuery.extend 在深复制时,为什么需要判断 isPlainOjbect?(不是问 isPlainOjbect 方法的原理)
自己想通了==
```
function Person(){
this.name
= "张三";
}
let person = new Person();
person.age = 12;
```
上面的 person 就是一个非 plain object,person 的__proto__为 Person,在使用 for in 遍历复制之后的对象的__proto__却变成了 Object,显然复制前后不对等,故要使用 isPlainObject 方法进行过滤
关于
·
帮助文档
·
博客
·
API
·
FAQ
·
我们的愿景
·
实用小工具
·
2276 人在线
最高记录 6543
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 11ms ·
UTC 06:17
·
PVG 14:17
·
LAX 23:17
·
JFK 02:17
Developed with
CodeLauncher
♥ Do have faith in what you're doing.