1

In JavaScript Programming language, I have seen the condition:

 if(data=== 'y') 

I can't understand the operator ===. Someone please explain the purpose of this operator.

Nathan Hughes
  • 94,330
  • 19
  • 181
  • 276
Monisha
  • 89
  • 1
  • 6
  • 2
    possible duplicate of [Does it matter which equals operator (== vs ===) I use in JavaScript comparisons?](http://stackoverflow.com/questions/359494/does-it-matter-which-equals-operator-vs-i-use-in-javascript-comparisons) – Lordbalmon Aug 07 '15 at 12:17

2 Answers2

2

It means that the data types have to be same, as well as the values, for the expression to be true.

By the way, Java does not have this operator. Do you mean Javascript?

Bathsheba
  • 231,907
  • 34
  • 361
  • 483
2

The operator === is used to determine that whether both the value and the data types are same or not whereas the operator == only checks for the value. See an example here

Itban Saeed
  • 1,660
  • 5
  • 25
  • 38