Skip to content

Commit

Permalink
完善new
Browse files Browse the repository at this point in the history
  • Loading branch information
abstain23 committed Jun 3, 2020
1 parent a35eeb2 commit 55d948e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion 手写实现new.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ function copyNew(){
const Constructor = [...arguments][0]
obj.__proto__ = Constructor.prototype
const res = Constructor.apply(obj,[...arguments].slice(1))
return typeof res === 'object' ? res : obj
return res && (typeof res === 'object') ? res : obj
}

0 comments on commit 55d948e

Please sign in to comment.