javascript switch/case : are types compared? -


possible duplicate:
is safe assume strict comparison in javascript switch statement?

does switch/case statement in javascript compare types or values?

in other words, when have following code:

switch (variable) {     case "0": [...] break;     case "1": [...] break;     default: [...] break; } 

is equivalent to

if ( variable == "0" ) {     [...] } else if ( variable == "1" ) {     [...] } else {     [...] } 

or to

if ( variable === "0" ) {     [...] } else if ( variable === "1" ) {     [...] } else {     [...] } 

edit: there way force compare values , types @ once?

yes, types compared.

if input equal clauseselector defined === operator, set found true.

ecma-262, page 95.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -