1// var declares a variable, meaning its value will vary.
2// const declares a constant, meaning its value will remain
3// consistant and not change.
4// If your variable changes throughout the program or website,
5// declare it using a var statement.
6// Otherwise, if its value does not change, declare it using
7// a const statement.
8
9const myConst='A const does not change.';
10
11var myVar='A var does change.';
12
13var myVar=2;
1// The const keyword was introduced in ES6 (2015).
2
3// Variables defined with const cannot be Redeclared.
4
5// Variables defined with const cannot be Reassigned.
6
7// Variables defined with const have Block Scope.
1/*The destructuring assignment syntax is a JavaScript expression that
2makes it possible to unpack values from arrays, or properties from objects,
3 into distinct variables.*/
4 let array = [2,3];
5 [a,b] = array;// unpacking array into var a and b
6 console.log(a); //output 2
7 console.log(b); //output 3
8 let object = {name:"someone",weight:"500pounds"};
9 let {name,weight} = object; // unpacking object into var name and weight
10 console.log(name);// output someone
11 console.log(weight);//output 500pounds
12
13//it i similar as doing this
14/*
15var a = array[0];
16var b = array[1]
17var name = object.name;
18var weight = object.weight;
19
20 */