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 = { | |
| name: 'Ayame' | |
| }; | |
| obj = { | |
| name: 'Lucius' | |
| } // Error: "obj" is read-only | |
| obj.name = 'Carolina'; |
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 quantity = 3; | |
| if (quantity > 2) { | |
| let anotherQuantity = 10; | |
| } | |
| console.log(anotherQuantity) // Error: anotherQuantity is not defined |
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 quantity1 = 1; | |
| const quantity1 = 2; // Error: Duplicate declaration "quantity" | |
| const quantity2 = 5; | |
| quantity2 = 6; // Error: "quantity2" is read-only | |
| const quantity3; // Error: unexpected token ; |
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 counter = 2; | |
| function fn() { | |
| console.log('Inside fn before loop:', counter); // 2 | |
| for (counter = 0; counter < 5; counter++) { | |
| console.log(counter); // 0, 1, 2, 3, 4 | |
| } | |
| counter += 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
| var quantity = 1; | |
| var quantity = 2; | |
| quantity = 3; | |
| if (quantity > 2) { | |
| var anotherQuantity = 10; | |
| } | |
| console.log(anotherQuantity) // 10 <- leaked outside the if block | |
| console.log(quantity); // 3 |