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 Person() { | |
| this.firstname = 'John' | |
| this.lastname = 'Doe' | |
| } | |
| var john = new Person(); | |
| var Sally = new Person(); | |
| console.log(john); | |
| console.log(sally); |
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 Person() { | |
| console.log(this); | |
| } | |
| var john = new Person(); | |
| //=> Person {} |
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 Person() { | |
| this.firstname = ‘John’ | |
| this.lastname = ‘Doe’ | |
| console.log(`This function is invoked!`) | |
| } | |
| var john = new Person(); | |
| //=> "This function is invoked!" |
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
| console.log(john); | |
| // => Person {Firstname: “John”, Lastname: “Doe” } |
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 john = new Person(); | |
| function Person() { | |
| this.firstname = ‘John’ | |
| this.lastname = ‘Doe’ | |
| } |
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 InformalPerson extends Person { | |
| constructor(firstname, lastname) { | |
| super(firstname, lastname); | |
| } | |
| greet () { | |
| return 'Yo ' + firstname; | |
| } | |
| } |
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 Person { | |
| constructor(firstname, lastname) { | |
| this.firstname = firstname; | |
| this.lastname = lastname; | |
| } | |
| greet () { | |
| return 'hi ' + firstname; | |
| } | |
| } |
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 greet() { | |
| console.log('hi') | |
| } | |
| greet.language = 'english' | |
| console.log(greet.language) | |
| // => 'english' |
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 greet() { | |
| console.log('hi') | |
| } |
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 a = ["yo", "whadup", "?"]; | |
| // Arrays inherit from Array.prototype | |
| // (which has methods like indexOf, forEach, etc.) | |
| // The prototype chain looks like: | |
| // a ---> Array.prototype ---> Object.prototype ---> null |