You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- You can use access this variable before declaration with undefined value.
9
+
- You can declare variable using var and also You can assign values later.
10
+
- You can redeclare same name variable anywhere by assining new value. If You do not assign value then it will hold previous assigned value.
11
+
- It does not support scope resolution means it can access anywhere. So, declared variable in outside block {} and inside block {} with same name, both variables are same and hold same value and accessible both side. So if You modify or redeclare variable then it will make changes for all.
12
+
- var variable can be access in functions if and only if function must not have redeclaration of same name variable with var, let and const. If You redeclare same variable in function with var,let or const, then it will create seperate local variable with same name only for function with assigned new value or undefined by default.
13
+
14
+
let :
15
+
- You can not access this variable before declaration otherwise you will get error.
16
+
- You can declare variable using let and also You can assign values later.
17
+
- You can not redeclare same name variable within block{} but You can redeclare same name variable in other {} block.
18
+
- It supports scope resolution means variable can be access only within scope block{} and inner all {} and functions. It can not be accessed out of the scope means inner block{} variables can not be access in outside block.
19
+
- let variable can be access in functions if and only if function must not have redeclaration of same name variable with var, let and const. If You redeclare same variable in function with var,let or const, then it will create seperate local variable with same name only for function with assigned new value or undefined by default.
20
+
21
+
const :
22
+
- You can not access this variable before declaration otherwise you will get error.
23
+
- You can declare variable using const and you must by assigning values otherwise it will create error.
24
+
- Const variable must be initialized when it was declared. You can not initialize later.
25
+
- Only Primitive data type can be constant so other can modify even if You assign constant.
26
+
- After assiging value, You can not modify value.
27
+
- You can not redeclare same name variable within block{} but You can redeclare same name variable in other {} with assign value.
28
+
- It supports scope resolution means variable can be access only within scope block{} and inner all {} and functions. It can not be accessed out of the scope means inner block{} variables can not be access in outside block.
29
+
- const variable can be access in functions if and only if function must not have redeclaration of same name variable with var, let and const. If You redeclare same variable in function with var,let or const, then it will create seperate local variable with same name only for function with assigned new value.
This mode allow to use variable which are defined with var,let and const. If you use variable without declare then it will give error 'ReferenceError': variable is not defined
Template literals are an alternative way of working with strings, which was introduced in the ES6 addition to the JavaScript language.
5
+
6
+
With template literals, an expression can be embedded in a placeholder. A placeholder is represented by ${}, with anything within the curly brackets treated as JavaScript and anything outside the brackets treated as a string
7
+
*/
8
+
9
+
vargreet="Hello";
10
+
varplace="World";
11
+
console.log(greet+" "+place+" !");
12
+
console.log(`${greet}${place} !`)//display both variables using template literals
0 commit comments