Answers for "how to do a try catch in javascript"

113

try catch in javascript

try {
  // Try to run this code 
}
catch(err) {
  // if any error, Code throws the error
}
finally {
  // Always run this code regardless of error or not
  //this block is optional
}
Posted by: Guest on June-12-2020
31

javascript try

var someNumber = 1;
try {
  someNumber.replace("-",""); //You can't replace a int
} catch(err) {
 console.log(err);
}
Posted by: Guest on June-27-2019

Code answers related to "Javascript"

Browse Popular Code Answers by Language