5

I have seen many places where angular js uses triple equals sign === to compare two elements why not 2 equalsenter image description here== . I am just wondering is there any specific reason for that ?

Barry
  • 3,683
  • 1
  • 18
  • 25
DeepInJava
  • 1,871
  • 3
  • 16
  • 31

1 Answers1

22

The === operator checks value and type while the == operator only checks value, simple example

1 == "1" -> true
1 === "1" -> false (types are not equal)

Sometimes you want to use this strict comparison, especially when checking a boolean value.

1 == true -> true
1 === true -> false (types are not equal)
Barry
  • 3,683
  • 1
  • 18
  • 25