Skip to content

Commit e88ad3d

Browse files
committedJul 8, 2020
use Object.assign
1 parent 83fc8b2 commit e88ad3d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed
 

‎src/index.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
function omit(obj, fields) {
2-
const shallowCopy = {
3-
...obj,
4-
};
2+
// eslint-disable-next-line prefer-object-spread
3+
const shallowCopy = Object.assign({}, obj);
54
for (let i = 0; i < fields.length; i += 1) {
65
const key = fields[i];
76
delete shallowCopy[key];

1 commit comments

Comments
 (1)

zoubingwu commented on Jul 13, 2021

@zoubingwu

@afc163 Hey I was wondering why use Object.assign to replace spread operator here? The spread operator should have a better performance actually, you could check the comparison here

Please sign in to comment.