开发者

Difference between "==" and "===" in java script [duplicate]

This question already has answers here: Closed 12 years ago.

Possible Duplicate:开发者_高级运维

Javascript === vs == : Does it matter which “equal” operator I use?

Hi I am not clear why there are two == and === comparator operators in java script.


The equality operator == coerces, or converts the data type temporarily to see if it's equal to the other operand whereas the identity operator === doesn't need to do any converting whatsoever since it directly compares them without conversion meaning it's stricter and faster.

2=='2'
true

2==='2'
false
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜