Can someone please explain to me why the following javascript code produces an alert with 321 and the PHP code produces 1.
I know the PHP code evaluates the expression and returns true or false. What I don't know is why in JavaScript it works like a ternary operator. Is it just the way things were implemented in the language?
var something = false; var somethingelse = (something || 321); alert(somethingelse); // alerts 321
$var = '123'; $other = ($var || 321); echo $other; // prints 1
Thanks!