|
|
|
|
|
by barrkel
5286 days ago
|
|
I would expect 'hello' + 1 to throw an exception. I would similarly expect '5' - 3 to throw an exception. Why? Because you can't add a string to an integer, and nor can you subtract an integer from a string. Doing anything else is arbitrary and unpredictable, IMO, leading to subtle type errors. You want to find type errors early as possible, rather than letting bogus values flow through the program. I think Javascript is broken here, and Python has it right. |
|
Javascript thinks to itself 'hello' string concatenated with a 1 value.