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 Animal { | |
| constructor(name) { | |
| this.name = name | |
| } | |
| eat() { | |
| console.log(`${this.name} is eating`); | |
| } | |
| } |
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 Animal = function (name) { | |
| this.name = name; | |
| } | |
| Animal.prototype.eat = function () { | |
| console.log(this.name + ' is eating!'); | |
| } | |
| var Dog = function (name) { | |
| Animal.call(this, name); |
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 () { | |
| var gandalfQuote = 'You shall not pass!'; | |
| })(); | |
| console.log(gandalfQuote); |
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(person); | |
| var person = 'Jon Snow'; |
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 goodGuys = ['Frodo', 'Sam', 'Gandalf']; | |
| for (var i = 0; i < goodGuys.length; i++) { | |
| console.log(goodGuys[i]); | |
| } | |
| console.log(i); |
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
| person = 'Jon Snow'; | |
| var person; | |
| console.log(person); |