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

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -