Grokking Advanced JavaScript
Vote

0% completed

​

Common Mistakes

Each mistake below has one thing in common with the others: the code runs without any error message and produces a wrong result. Such bugs are harder to find than a crash, because nothing points to the line that caused them. The examples follow one small shopping cart, so that each mistake appears in the kind of code where it really occurs.

Mistake 1: Comparing with == Instead of ===

A cart reads the quantity from a form field, and form fields always deliver strings. The program then compares that string with a number.

quantity == input: true quantity === input: false

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content