O'Reilly logo
  • Ahmed Elgendy thinks this is interesting:

: Is + always interpreted as string concatenation when one of the operands is a string?


A: Yes. However, because + has what is called left-to-right associativity, if you have a situation like this:

var order = 1 + 2 + " pizzas";

you’ll get “3 pizzas”, not “12 pizzas” because, moving left to right, 1 is added to 2 first (and both are numbers), which results in...


Cover of Head First JavaScript Programming


What is the left associativity of + operator?