throwing error in JS code example
Example 1: js throw error
throw new Error('Whoops!')
Example 2: javascript throw new error
throw new Error("Error message here"); // Uncaught Error: Error message here
Example 3: try catch throwing error in javascript
let json = '{ "age": 30 }'; // incomplete data
try {
let user = JSON.parse(json); // <-- no errors
alert( user.name ); // no name!
} catch (e) {
alert( "doesn't execute" );
}