27

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 Javascript.

If possible please provide a simple example

Community
  • 1
  • 1
  • 7
    Duplicate of [Javascript === vs == : Does it matter which "equal" operator I use?](http://stackoverflow.com/questions/359494/javascript-vs-does-it-matter-which-equal-operator-i-use) – James McNellis Aug 24 '10 at 04:19
  • visit this http://stackoverflow.com/questions/523643/difference-between-and-in-javascript, it is somehow related to your question... – Manie Aug 24 '10 at 04:19
  • You can always check the latest official standard for EcmaScript, [ECMA-262, 5th Edition](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf). EcmaScript is the basic language of what is commercialized as JavaScript (browsers), ActionScript (Adobe Flash), etc. – JanC Aug 24 '10 at 04:26

3 Answers3

33

=== 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' 
viksit
  • 7,542
  • 9
  • 42
  • 54
13

=== 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.

leonheess
  • 16,068
  • 14
  • 77
  • 112
rubayeet
  • 9,269
  • 8
  • 46
  • 55
0

please refer Strict Equality Check..

Rakesh Goyal
  • 3,117
  • 8
  • 39
  • 69