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
| 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
| 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' | |
| } | |
| 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(firstname, lastname) { | |
| this.firstname = firstname | |
| this.lastname = lastname | |
| } | |
| var john = new Person(‘john’, ‘doe’); | |
| var sally = new Person(‘sally’, ‘white’); | |
| //=> Person { Firstname: “John”, Lastname: “Doe” } | |
| //=> Person { Firstname: “Sally”, Lastname: “White” } |
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 width = 100; | |
| console.log (width); //=> 100 |
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 width = 100; | |
| console.log (width); //=> 100 | |
| var width = 200 | |
| console.log (width); //=> 200 |
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 setWidth() { | |
| var width = 100; | |
| console.log(width); | |
| } | |
| /// width not available here |
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
| if(age > 12) { | |
| const dogYears = age * 7 | |
| console.log(‘You are ${dogYears} dog years old!’) | |
| } | |
| //=> dogYears not available here |
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
| if(age > 12) { | |
| let dogYears = age * 7 | |
| console.log(‘You are ${dogYears} dog years old!’) | |
| } | |
| //=> dogYears not available here |