Skip to content

Instantly share code, notes, and snippets.

@fancn21th
Forked from gaearon/Classes.js
Created July 9, 2022 04:00
Show Gist options
  • Save fancn21th/2d89d5c9e7d7ccf8bb971b36bed5c15c to your computer and use it in GitHub Desktop.
Save fancn21th/2d89d5c9e7d7ccf8bb971b36bed5c15c to your computer and use it in GitHub Desktop.

Revisions

  1. @gaearon gaearon created this gist May 27, 2020.
    8 changes: 8 additions & 0 deletions Classes.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    class Spiderman {
    lookOut() {
    alert('My Spider-Sense is tingling.');
    }
    }

    let miles = new Spiderman();
    miles.lookOut();
    10 changes: 10 additions & 0 deletions Prototypes.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    // class Spiderman {
    let SpidermanPrototype = {
    lookOut() {
    alert('My Spider-Sense is tingling.');
    }
    };

    // let miles = new Spiderman();
    let miles = { __proto__: SpidermanPrototype };
    miles.lookOut();