JavaScript === vs == for type checking -


which of following lines correct?...

if (typeof value == 'boolean') { return value; } 

... or ...

if (typeof value === 'boolean') { return value; } 

i thought double equal sign type of "soft compare" value variable either string or formal type. not so? wonder because jshint complained first version. i've changed i'm worried typeof won't return string.

== soft compare, typeof returns string.

https://developer.mozilla.org/en-us/docs/web/javascript/reference/operators/typeof


Comments

Popular posts from this blog

c# - Class in a list -

mysql - Django database model for my website -

ios - How to run a segue on itself OR another viewController -