Javascript - Common Error Types
Code Life
By Pierre Marsaa
Every Error Has a Family Name
Almost every error you will meet in JavaScript belongs to one of four families: TypeError, ReferenceError, RangeError, or SyntaxError.
The most common of all is TypeError. It happens when you try to use a value in a way that its type does not support — like reading a property on undefined, or calling a number as if it were a function:
↗️
Loading editor...
↶
↷
Because level is a number (5) and not a function, calling level() throws TypeError: level is not a function.
Whenever you see TypeError, ask yourself: *"What kind of value did this line expect, and what value did it actually receive?"*
Verify