Tutorial by Examples

6 Exceptions are to synchronous code what rejections are to promise-based asynchronous code. If an exception is thrown in a promise handler, its error will be automatically caught and used to reject the promise instead. Promise.resolve(5) .then(result => { throw new Error("I ...
Runtime errors in JavaScript are instances of the Error object. The Error object can also be used as-is, or as the base for user-defined exceptions. It's possible to throw any type of value - for example, strings - but you're strongly encouraged to use Error or one of it's derivatives to ensure that...
Without a try catch block, undefined functions will throw errors and stop execution: undefinedFunction("This will not get executed"); console.log("I will never run because of the uncaught error!"); Will throw an error and not run the second line: // Uncaught ReferenceError:...
There are six specific core error constructors in JavaScript: EvalError - creates an instance representing an error that occurs regarding the global function eval(). InternalError - creates an instance representing an error that occurs when an internal error in the JavaScript engine is thr...

Page 1 of 1