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
| const sayMyName = (name) => { alert(‘Hello ${name})! } | |
| sayMyName(‘Erik’); | |
| => Hello Erik! |
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
| const winners = [‘racer1’, ‘racer2’, ‘racer3’, ‘racer4’]; |
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
| const race = ‘100m dash’ |
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
| { | |
| name: `racer1`, | |
| race: `position` | |
| place: 1 | |
| } |
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
| const results = winners.map((winner, i) => ({name: winner, race: race, place: 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
| const button = document.querySelector(‘.button’); | |
| buttton.addEventListener(‘click, () => { | |
| this.classList.toggle(‘on’); //=> error!!! This is defined globally. | |
| }); |
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
| buttton.addEventListener(‘click, function() { | |
| this.classList.toggle(‘on’); //=> error!!! This is defined globally. | |
| }); |
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
| const obj = function() {}; | |
| obj.prop = 'object\'s property'; | |
| console.log(obj.prop); |
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
| // Creating the first prototype | |
| const proto1 = function() {}; | |
| proto1.prop2 = 'protos property'; | |
| const obj = Object.create(proto1); | |
| obj.prop = 'object\'s property'; | |
| console.log(obj.prop); | |
| console.log(obj.prop2); |
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
| // Creating the second prototype | |
| const proto2 = function () {}; | |
| proto2.prop3 = "proto 2's property" | |
| // Creating the first prototype | |
| const proto1 = Object.create(proto2) | |
| proto1.prop2 = 'protos property'; | |
| const obj = Object.create(proto1); | |
| obj.prop = 'object\'s property'; |