Why javascript console.log(1 + + " " + 3); sentence returns 4 and not "1 3"? -
when statement console.log(1 + + " " + 3);
executed in chrome console, result 4
, not "1 3"
expect.
can please explain why case?
this behaviour called coercion.
in case unary plus operator +
converts number expression @ right. if cannot parse particular value, evaluate nan.
+ " " //--> coerced 0
you can see coercion examples in gist: javascript coercion
Comments
Post a Comment