How do errors occur and can you create an error object?
Errors result when there is a problem with code execution in the runtime . When this happens, the runtime will generate an Error object with information about what just happened. There are instances where developers can create user-defined errors that can be useful when debugging.
new Array(-1) //returns Uncaught RangeError: Invalid array length
//user defined error
console.log(new Error('this is a problem')); //returns ...