JavaScript for impatient programmers (beta)
Please support this book: buy it or donate
(Ad, please don’t block.)

4. FAQ: JavaScript

4.1. Why does JavaScript fail silently so often?

JavaScript often fails silently. Let’s look at two examples.

First example: If the operands of an operator don’t have the appropriate types, they are converted as necessary.

> '3' * '5'
15

Second example: If an arithmetic computation fails, you get an error value, not an exception.

> 1 / 0
Infinity

Why is that?

The reason is historical: JavaScript did not have exceptions until ECMAScript 3. Since then, its designers have tried to avoid silent failures.