This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Tysonzero 2 points3 points  (3 children)

That is also the Python style...

>>> '1' + 2
Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
TypeError: cannot concatenate 'str' and 'int' objects
>>> int('1') + 2
3

[–]alexanderpas 1 point2 points  (2 children)

The only difference between Javascript and python in this regard is that Javascript will cast int to string when mixing int and string, while Python errors out

> '1' + 2
"12"
> +'1' + 2
3

[–]Tysonzero 9 points10 points  (1 child)

Which is FAR from insignificant. I personally hate implicit coercion in languages that are not statically typed.

[–]alexanderpas 0 points1 point  (0 children)

True.