Skip to content

Instantly share code, notes, and snippets.

@codecakes
Created November 13, 2024 09:35
Show Gist options
  • Save codecakes/87edcb09e84328fe733ee4ddb98a2bd5 to your computer and use it in GitHub Desktop.
Save codecakes/87edcb09e84328fe733ee4ddb98a2bd5 to your computer and use it in GitHub Desktop.
People have forgotten classes object instantiation in JS
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