PHP and Javascript make comparisons differently? -


the below php code outputs yes

if("2"== true){     echo "yes"; } else{ echo "no"; } ?> 

but below javascript code alerts no

 <script>     if("2" == true){             alert('yes');         }         else{             alert('no');          }    </script> 

i dont knw how these statements execute in other languages. why outputs different?

in php "==" checks if value set, automaticly true.

in js there type conversion check values. true converted "1" , "1" not equal "2".


Comments