alert("test: "+(1==2)?'hello':'world');
This should show me 'world' on the screen since 1 is not equal to 2.
'world'
How come it alerts 'hello'?
'hello'
Try wrapping your parens around the operation
alert("test: "+ (1 == 2 ? 'hello' : 'world'));
demo: http://jsfiddle.net/hunter/K3PKx/
what this is doing:
is evaluating "test: " + (1==2) as true which outputs 'hello'
"test: " + (1==2)
true
1.4m articles
1.4m replys
5 comments
57.0k users