One of the things we dread when learning JavaScript is the red error message on the console. You just have to look at the error message, it is very easy to solve the error.
Here are some common error types:
SyntaxError
Grammar mistakes
This is probably the most common mistake you can make when you start writing code
TypeError
Type error
Now, why is the error message not test is not defined? Because obj.test is accessible, print its value as undefined, which is due to the special design of JS. In other words, the system determines that you mistook test as a function and therefore as a type error
ReferenceError
Reference error
This is easy to understand, you reference the variable is not defined, not even undefined, you can’t find anything