What is === operator?

What is === operator?

“===” is used as a comparision operator in javascript through which you can compare two values.
e.g.
let a=2;
let b=2;
if(a===b){
document.write(“Equal”);
}
else{
document.write(“Not Equal”);
}
output:
Equal

“===” this comparison operator checks for the value and the type of the value,
in the below example the output will be “NOT EQUAL” because the type of a and b are not the same even if the value is the same.

example:-
a = 2;;
b= ‘2’;

if(a===b) {
console.log(‘IT IS EQUAL’)
} else {
console.log(‘NOT EQUAL’)
}

“==” this operator just checks for the value and does not care for the type of the value,
in the below example the output will be “IT IS EQUAL” because the value of a and b are equal.

example:-
a = 2;;
b= ‘2’;

if(a==b) {
console.log(‘IT IS EQUAL’)
} else {
console.log(‘NOT EQUAL’)
}

*try to use “===” over “==” where ever possible.