Answers for "js throwing errors"

9

javascript throw new error

throw new Error("Error message here"); // Uncaught Error: Error message here
Posted by: Guest on June-06-2020
0

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" );
}
Posted by: Guest on December-01-2020
0

js throwing errors

throw "Too big";    // throw a text

throw 500;          // throw a number
Posted by: Guest on October-03-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language