There are two different ways to handle errors in JavaScript. You can treat them as variables, or throw them. Both have their use cases, and you can convert back and forth between them using design patterns. Lets take a look at how each behave.
If you are coming from another language, you are probably already familiar with try catch. Here is a basic example:
function trycatch() {