BVernon
BVernon

Reputation: 3747

Are these comparisons equivalent in Javascript?

In Javascript, is

return (someBooleanValue == true)

necessarily always the same as

return someBooleanValue

?

Upvotes: 0

Views: 34

Answers (2)

Bergi
Bergi

Reputation: 664195

If you assume that typeof someBooleanValue is 'boolean', then Yes these are equivalent (by pure boolean logic).

For everything else, they are not.

Upvotes: 1

Ryan Nigro
Ryan Nigro

Reputation: 4619

Iff someBooleanValue is a boolean value, then yes. For any other object/value, then no.

Upvotes: 1

Related Questions