0

I am using java script to compare values

 if (cellValue == "true" || cellValue == true)

Instead of doing this can i use the ===operator in java script ?

2
  • Why would you have to compare to "true"? Commented Mar 22, 2016 at 15:26
  • Have you tried to use it to see what happens? Commented Mar 22, 2016 at 15:27

1 Answer 1

2

The difference between == and === is that the first one (double equals) does type coercion, which can lead to goofy results:

0 == false
true

0 === false
false

It is usually recommended to use === as that will provide more predictable results and evaluate the true types of the values you're comparing.

Sign up to request clarification or add additional context in comments.

Comments