Skip to content

Instantly share code, notes, and snippets.

View ernes-to's full-sized avatar

Ernesto Rodriguez ernes-to

  • Austin, TX
  • 02:51 (UTC -06:00)
View GitHub Profile
const obj = {
name: 'Ayame'
};
obj = {
name: 'Lucius'
} // Error: "obj" is read-only
obj.name = 'Carolina';
const quantity = 3;
if (quantity > 2) {
let anotherQuantity = 10;
}
console.log(anotherQuantity) // Error: anotherQuantity is not defined
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 ;
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;
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