Different between
โ โโ Equality(==) and
โ Strict Equality (===)
operators in JavaScript ๐
Thread ๐งต
Equality operator (==)
โข If we compare two values but the data type of the values is not the same, then the equality operator first performs a type conversion and then evaluates them.
โข Example :
console.log(3==3); //return true
console log(3=='3'); //also return true
Strict Equality operator (===)
โข The strict equality operator will compare both data type and value without converting one data type to the other or without performing any type conversion.
โข Example :
console.log(3===3); //return true
console.log(3==='3'); //return false
Similarly ๐
Inequality operator (!=)
โข firstly perform type conversion then compare the values
โข Example :
console.log(1!=1); //false
console.log(1!='1'); //false
Strict Inequality operator(!==)
โข Compare both data type and values without performing any type conversions
โข Example:
console.log(1!==1); //false
console.log(1!=='1'); //true
End thread ๐งต
If this thread helpful for you then
1. Do Retweet the FIRST TWEET.
2. Follow me and turn on the notifications: @personalvipin
Thankyou โฃ๏ธ