alert("test: "+(1==2)?'hello':'world');
This should show me 'world' on the screen since 1 is not equal to 2.
How come it alerts 'hello'?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try wrapping your parens around the operation
demo: http://jsfiddle.net/hunter/K3PKx/
what this is doing:
is evaluating
"test: " + (1==2)astruewhich outputs'hello'