Equality VS Identity operator JavaScript
Published in
2 min readMar 5, 2018
( 4 == '4') == (4 === '4')
Result will be true
or false
??
# Equality Operator : ( == )
Equality ( == )
operators compare same type of data . if comparision any element has different data type
that time automatically convert
same data type
4 == '4' // number and string // but output true
so auto convert for equality purpose
4 == 4 or '4' == '4' // output true
# Identity operator ( === )
Identity operator task is same but if any comparison element has different data type, that time output will be false.
4 === '4' // number and string // output false
NB: use
===
instead of==
for comaparision purpose
@code4mk / code4mk