Skip to content

Commit ce5de76

Browse files
committed
docs(object): edit object'clone
1 parent 22b0f1d commit ce5de76

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

docs/object.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1371,9 +1371,15 @@ const clone2 = Object.assign(
13711371
Object.create(Object.getPrototypeOf(obj)),
13721372
obj
13731373
);
1374+
1375+
// 写法三
1376+
const clone3 = Object.create(
1377+
Object.getPrototypeOf(obj),
1378+
Object.getOwnPropertyDescriptors(obj)
1379+
)
13741380
```
13751381

1376-
上面代码中,写法一的`__proto__`属性在非浏览器的环境不一定部署,因此推荐使用写法二
1382+
上面代码中,写法一的`__proto__`属性在非浏览器的环境不一定部署,因此推荐使用写法二和写法三
13771383

13781384
扩展运算符可以用于合并两个对象。
13791385

0 commit comments

Comments
 (0)