Skip to content

Instantly share code, notes, and snippets.

@ashwanisindhu-2
Forked from gaearon/Classes.js
Created June 11, 2021 05:19
Show Gist options
  • Save ashwanisindhu-2/8e7cefa15619f3a16997eeee2f7f3030 to your computer and use it in GitHub Desktop.
Save ashwanisindhu-2/8e7cefa15619f3a16997eeee2f7f3030 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