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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script src="script-1.js"></script> | |
| <script src="script-2.js"></script> | |
| <script src="script-3.js"></script> | |
| </head> | |
| <body> | |
| </body> | |
| </html> |
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
| let value = 0; | |
| if (true) { | |
| // new scope, TDZ of 'value' begins | |
| // When trying to access the variable, we take ReferenceError, | |
| // because right now it's a variable | |
| // not initialized | |
| console.log (value); // ReferenceError | |
| let value; // TDZ ends and 'value' is set to 'undefined' | |
| console.log (value); // undefined | |
| value = 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 arrayVar = []; | |
| for (var i = 0; i <5; i ++) { | |
| arrayVar.push (function () { | |
| console.log (i); | |
| }); | |
| } | |
| i = 10; // assigning a new value | |
| arrayVar.forEach (function) { | |
| occupation(); // 10 10 10 10 10 | |
| }); |
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
| arrayVar.forEach (function) { | |
| occupation(); // 5 5 5 5 5 | |
| }); | |
| arrayLet.forEach (function) { | |
| occupation(); // 1 2 3 4 5 | |
| }); |
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 arrayLet = []; | |
| for (let i = 1; i <5; i ++) { | |
| arrayLet.push (function () { | |
| 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
| const arrayVar = []; | |
| for (var i = 1; i <5; i ++) { | |
| arrayVar.push (function () { | |
| 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
| // examples | |
| var object = {}; // object | |
| var number = 1; // number | |
| var name = "Keys"; // string | |
| var list = [1,2,3]; // list |
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 song1 = { | |
| title: 'Love has no rollback', | |
| author: 'SQL' | |
| } | |
| var songs = new Set ([song1]); | |
| console.log (songs); | |
| song1 = null; |
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 song1 = { | |
| title: 'Love has no rollback', | |
| author: 'SQL' | |
| } | |
| var songs = new WeakSet ([song1]); | |
| console.log (songs); | |
| // WeakSet {Object {title: "Love has no rollback", author: "SQL"}} |
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 songs = new Set ([ | |
| 'song1', 'song1', 'song1' | |
| ]); | |
| var songsAmount = songs.size; | |
| console.log ("There are" + songsAmount + "songs in the list"); | |
| // There are 3 songs in the list |