Typefully

Difference between Equality and Strict Equality Operator in JavaScript ๐Ÿš€

Avatar

Share

ย โ€ขย 

3 years ago

ย โ€ขย 

View on X

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 โฃ๏ธ
Avatar

Vipin

@SocialWithAI

HTML is ๐Ÿ”ฅ | CSS is โฃ๏ธ Hi ๐Ÿ‘‹ I'm Vipin, I'm learning web2 and sharing my knowledge with you guys in easy ways.