This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Parent { | |
| constructor(name) { | |
| this.name = name; | |
| } | |
| } | |
| Parent.prototype.greet = () => { | |
| console.log(`Hi, I'm ${this.name}`); | |
| } | |
| var mom = new Parent("Mom"); | |
| mom.greet() // "Hi, I'm Mom" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Parent { | |
| constructor(name) { | |
| this.name = name; | |
| } | |
| greet() { | |
| console.log(`Hi, I'm ${this.name}`); | |
| } | |
| } | |
| var mom = new Parent("Mom"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function NEW(constructor, argsArray) { | |
| var obj = {}; // step 1 | |
| obj.__proto__ = constructor.prototype; // step 2 | |
| constructor.apply(obj, argsArray); // step 3 | |
| return obj; // step 4 | |
| } | |
| function Parent(name) { | |
| this.name = name; | |
| } | |
| Parent.prototype.greet = function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var test = "hello world" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var test = hello world |
NewerOlder