News for hackers. Stuff that matters.
Re:John Resig: JavaScript as a First Language by barrkel on Wednesday December 21, 2011 @09:29PM (#3380077)
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.

Re:John Resig: JavaScript as a First Language by maximusprime on Thursday December 22, 2011 @05:00AM (#3381046)
You're conveniently ignoring the fact that the + operator also means string concatenation.

Javascript thinks to itself 'hello' string concatenated with a 1 value.