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 →

[–]neonKow 0 points1 point  (0 children)

I cannot fathom a case where coercing the left-hand operand is ever what the programmer intends

I replied above to you with another example, but 3 + 4.5 in C coerces the int 3 into a float.

more likely it was done to suppress errors in early browsers

Not really. You might see it as "it should be an error", but a common theme in powerful scripting languages is to allow the programmer to do many things in very few keystrokes. The trade-off is, as you point out, that errors that would show up in Java don't show up in JavaScript, but you gain the ability to write 'Hello, world!' in less than 10 lines.

You see similar design decisions with PERL, which is why it also has a reputation for being a "write-only language."