Created
November 13, 2024 09:35
-
-
Save codecakes/87edcb09e84328fe733ee4ddb98a2bd5 to your computer and use it in GitHub Desktop.
People have forgotten classes object instantiation in JS
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
Hi = (name) => { | |
x = Object.create(Hi.prototype); | |
x.name = name | |
return x; | |
} | |
Hi.prototype = { | |
name: null, | |
greet: function () { | |
return `Hello ${this.name}`; | |
} | |
}; | |
Hi.prototype.constructor = Hi; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment