Java Script
Decleration of variable
-> In order to delclare a variable in java script we need to use three key words
that is var let and const
D I D&I RI RD
--------------------------------------------
var yes yes yes yes yes
--------------------------------------------
let yes yes yes yes no
--------------------------------------------
const no no yes no no
--------------------------------------------
D -> Decleration
I -> Initilization
D&I -> Decleration and Initilaziton
RI -> Re-Initilazation
RD -> Re-Decleration
Arthmetic Operators
1) + -> Addition operator, example 1+2
2) - -> Subtraction operator , example 1-2
3) * -> Multiplecation operator , ex 2*3
4) / -> Division operator , ex 6/3
5) % -> Modulus operator , ex 4%2 = 0
6) ** -> To give the power to any number ,example 2^2 = 4 , 3^2 = 6
Comparation operator
1) == -> Compare only the value
ex let x = 10
let y = "10"
[Link](x==y) //true
2) === -> compare both the value and datatype
ex let x = 10
let y = "10"
[Link](x===y) //false
3) != -> Compare only the value
ex let x = 10
let y = "10"
[Link](x!=y) //true
4) !== -> compare both the value and the datatype
ex let x = 10
let y = "10"
[Link](x!==y) //false
let a = 10
let b = a++
let c= a++ + --b + a-- + ++b
[Link](a) // 11
[Link](b) // 10
[Link](c) // 42
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------
Statement
Conditional statement
1) if(condition){
----
} else {
---
}
2) if(condition1){
---
} else if(condition2){
----
}
else {
---
}
type coversion
->
-> there are two types
1) Implicit type conversion
Here java script it self covert one data type to another data type
depending on the situation
ex [Link](2+"3") // 23
[Link](5-"3") // 2
[Link](true + null) // 1 Because true will be converted to 1
and null will be converted to 0
[Link](undefined + false) // NaN ,not a number
2) Explicit type conversion
If we are converting manually the data type using a pre-defined method
called explicit type convertion
ex , [Link](parseInt("1abc")); //1
[Link](parseInt("abc12")); // NaN
[Link](Number(null)); // 0
[Link](Number(undefined)); // NaN
[Link](Number("1.234abc")); // NaN
[Link](Number(""); // 0
[Link](Number(" ")); // 0
[Link](Number(true); // 1
typeof operator
-> It is used to get the type of the variable
ex , clg(typeof 1) // number
[Link](typeof typeof 1); // string
[Link](typeof undefined); //undefined
[Link](typeof Number); //function
[Link](typeof Number()); //number
[Link](typeof typeof Number); //string
function sum(a , b ){
return a+b;
}
[Link](typeof sum); // function
[Link](sum);
[Link](typeof sum(2,2)); // number
[Link](typeof sum("hello" ," world")); // String
[Link](typeof {name:"xyz" , age:23}); //object
[Link](typeof null); //object
[Link](typeof [1,2,3,4]); //object