You are reading a single comment by @allObjects and its replies. Click here to read the full conversation.
  • ...would not waste much of breath on that (other than some comment in the doc)... operator overloading was always bad and gets worse with auto conversion in expressions with mixed types... Because I'm aware at design/coding time what is expected to be a number and what a string, I use parenthesis... (to be gentle - forcefully clear - to the underlaying system). I had to use that also when using shift operations with calculated shift values in compound expressions. The Foo example makes it perfetly clear...: the first + is obviously intended as a string concatenation, and the second an add which has precedence. When I need a string as a result and the concatenations starts with a number, I force string-precedence with "" + number1 + "string2" + (number2 + number3) + .... Alternative (on Browser) I like also [number1, "string2", number2 + number3, ...].join("");. I though do not know whether the alternatve creates a havoc for Espruino or some oder undesirable side effects.

About

Avatar for allObjects @allObjects started