开发者

What is === in javascript? [duplicate]

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

Possible Duplicate:

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

Looking into the answer of Chris Brandsma in Advanced JavaScript Interview Questions what is === in Javas开发者_开发百科cript.

If possible please provide a simple example


=== is the strict equal operator. It only returns a Boolean True if both the operands are equal and of the same type. If a is 2, and b is 4,

a === 2 (True)
b === 4 (True)
a === '2' (False)

vs True for all of the following,

a == 2 
a == "2"
2 == '2' 


=== is 'strict equal operator'. It returns true if both the operands are equal AND are of same type.

a = 2
b = '2'
a == b //returns True
a === b //returns False

Take a look at this tutorial.


please refer Strict Equality Check..

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜