-
-
Save vasylpb/c367b484cdf716d51148c9c5be8340b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function myNew(constructor, ...args) { | |
const obj = {} | |
Object.setPrototypeOf(obj, constructor.prototype); | |
return constructor.apply(obj, args) || obj | |
} | |
function Cat(color, name) { | |
this.color = color | |
this.name = name | |
} | |
const cat = myNew(Cat, 'black', 'Cat') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment