I have seen many places where angular js uses triple equals sign ===
to compare two elements why not 2 equals==
. I am just wondering is there any specific reason for that ?
Asked
Active
Viewed 1.8k times
5

Barry
- 3,683
- 1
- 18
- 25

DeepInJava
- 1,871
- 3
- 16
- 31
-
2http://stackoverflow.com/questions/359494/does-it-matter-which-equals-operator-vs-i-use-in-javascript-comparisons – New Dev Nov 05 '14 at 09:41
-
3its comes with javascript not comes with angularjs. – Kalhan.Toress Nov 05 '14 at 09:41
-
its javascript not angularjs, `===` is strict check. it checks data types and values. – Jai Nov 05 '14 at 09:44
1 Answers
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