1const age; // errror as const cannot be kept un-initialized;
2const age = 20 ;
3const age = 21 , // error as once declared const variable cann't be
4// re-declared in same scope or different scope.
5
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 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 */