#Day1 #BackToBasics
1) const and Let Keywords are introduced in Es6 2015.
2) LET : LET has a Block Scope
VAR : VAR has a Function Scope
Let: it signals that variable can be assigned reassigned a different value
(it means let can be reassigned).
eg:- let meal = 'Enchiladas';
console.log(meal); // Output: Enchiladas
meal = 'Burrito';
console.log(meal); // Output: Burrito
3) if we don't assign a value to a variable it will give an output of undefined.
4) Const: const was introduced in es6 it is constant. if you try to redefine const variable it will give you TypeError: Assignment to constant variable.
5) constant variables need to assign a value at the time of declaration and if you don't assign a value it will give you SyntaxError.
6) Mathematical Operators
7) +=,
8) -=
9) *=
10) /=
11) String Interpolation : it can be done with `` this BackTics.
eg:- const myPet = 'armadillo';
console.log(`I own a pet ${myPet}.`);
12) Typeof operator: return the typeof variables (string, num, etc...)
Let’s review what we learned:
Apply your learning with Projects based on Javascript Variables.do it now
1) Kelvin Project
2) Dog Years
Learn More here
1) const and Let Keywords are introduced in Es6 2015.
2) LET : LET has a Block Scope
VAR : VAR has a Function Scope
Let: it signals that variable can be assigned reassigned a different value
(it means let can be reassigned).
eg:- let meal = 'Enchiladas';
console.log(meal); // Output: Enchiladas
meal = 'Burrito';
console.log(meal); // Output: Burrito
3) if we don't assign a value to a variable it will give an output of undefined.
4) Const: const was introduced in es6 it is constant. if you try to redefine const variable it will give you TypeError: Assignment to constant variable.
5) constant variables need to assign a value at the time of declaration and if you don't assign a value it will give you SyntaxError.
6) Mathematical Operators
7) +=,
8) -=
9) *=
10) /=
11) String Interpolation : it can be done with `` this BackTics.
eg:- const myPet = 'armadillo';
console.log(`I own a pet ${myPet}.`);
12) Typeof operator: return the typeof variables (string, num, etc...)
Let’s review what we learned:
- Variables hold reusable data in a program and associate it with a name.
- Variables are stored in memory.
- The var keyword is used in pre-ES6 versions of JS.
- let is the preferred way to declare a variable when it can be reassigned, and const is the preferred way to declare a variable with a constant value.
- Variables that have not been initialized store the primitive data type undefined.
- Mathematical assignment operators make it easy to calculate a new value and assign it to the same variable.
- The + operator is used to concatenate strings including string values held in variables
- In ES6, template literals use backticks ` and ${} to interpolate values into a string.
- The typeof keyword returns the data type (as a string) of a value.
Apply your learning with Projects based on Javascript Variables.do it now
1) Kelvin Project
2) Dog Years
Learn More here
https://thetrains.in/ami-express/ have a look at this
ReplyDelete