Skip to content

Instantly share code, notes, and snippets.

@scootcho
Forked from gaearon/Classes.js
Created January 8, 2021 18:21
Show Gist options
  • Save scootcho/dec367e2df6f8741771be6db6936dd6f to your computer and use it in GitHub Desktop.
Save scootcho/dec367e2df6f8741771be6db6936dd6f 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