Java:
System.out.println("client " + authorized ? "authorized" : "unauthorized");
JavaScript:
alert(‘client ‘ + authorized ? ‘authorized’ : ‘unauthorized’);
(Let’s assume that the authorized is a parameter variable)
In Java, if you write code like this, you definitely get a compile time error, since String concatenation gets higher precedence than conditional operator whereas in JavaScript, you don’t get any error although String concatenation has higher precedence just like Java.
Reason for that is unlike Java which allows only true or false
[...Continue reading String Concatenation vs Conditional Operator in Java and JavaScript...]


Recent Comments