Skip to content

Instantly share code, notes, and snippets.

@iamsaief
Created August 22, 2020 12:06
Show Gist options
  • Save iamsaief/c27d862a805a915652e1452fda95bc50 to your computer and use it in GitHub Desktop.
Save iamsaief/c27d862a805a915652e1452fda95bc50 to your computer and use it in GitHub Desktop.
/* let, const */
let gf = "Jennifer Lawrence";
console.log(gf);
gf = "Elizabeth Olsen";
console.log(gf);
/**
* Output :
Jennifer Lawrence
Elizabeth Olsen
*/
const username = "willsmith";
username = "jhonshow"; //TypeError: Assignment to constant variable.
const number = [1, 2, 3, 4, 5];
number[1] = 10;
number.push(6);
console.log(number);
// Output: [ 1, 10, 3, 4, 5, 6 ]
const user = { name: "Shakib", age: 30 };
user.name = "Mushfiq";
user.profession = "Cricker";
console.log(user);
// Output: { name: 'Mushfiq', age: 30, profession: 'Cricker' }
/* Block Scope */
let sum = 0;
for (let i = 0; i < 5; i++) {
sum += i;
}
console.log(sum); // 10
console.log(i);
//ReferenceError: i is not defined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment