Skip to content

Instantly share code, notes, and snippets.

@wei-yuuuu
Forked from gaearon/Classes.js
Created July 23, 2021 03:37
Show Gist options
  • Save wei-yuuuu/8cb4489d5a47468280fff57444180c75 to your computer and use it in GitHub Desktop.
Save wei-yuuuu/8cb4489d5a47468280fff57444180c75 to your computer and use it in GitHub Desktop.
Beneath Classes: Prototypes
class Spiderman {
lookOut() {
alert('My Spider-Sense is tingling.');
}
}
let miles = new Spiderman();
miles.lookOut();
// class Spiderman {
let SpidermanPrototype = {
lookOut() {
alert('My Spider-Sense is tingling.');
}
};
// let miles = new Spiderman();
let miles = { __proto__: SpidermanPrototype };
miles.lookOut();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment