Flash cards
Review the key moves
What is the main idea behind JavaScript Silent Errors?
Lesson checks
Practice each idea before moving on
Short Mimo-style checks built from this lesson's code, terms, and sequence.
Which statement best captures the main point of this lesson?
Complete the missing token from the example code.
___ x = 1 / 0;Put the learning moves in the order that makes the concept easiest to apply.
Silent Errors
JavaScript can fail siently.
A silent error will not stop your program. The execution will continue.
The reason for silent errors is historical:
The first version of JavaScript did not have catch...try exceptions.
Silent errors are issues that do not throw exceptions or stop execution, but still cause logic bugs, unexpected behavior, or failures that are easy to miss.
Below are some examples of common silent errors, with examples to try:
Example
let x = 1 / 0;Example
let result = "Not Active.";
let isActive = false;
// ❌ Assignment, not comparison
if (isActive = true) {
let result = "Active!";
}Explanation
The (isActive = true) assigns true to isActive, instead of checking equality with (isActive == true).
The next line runs silently and prints "Active!", even though isActive is false.
Example
// NaN - no error, just wrong data
const result = parseInt("abc");Example
const user = {};
let result = user.name;Example
let result1 = ('5' + '2');
let result2 = ('5' - '2');See Also
JavaScript Errors
JavaScript Error Statemets
JavaScript Error Object
JavaScript Debugging