Error Handling in JavaScript


How to handle error in JavaScript ?

You can handle error in JavaScript by adding a try and catch block.

try{
  let k = 1/infinity;
} catch(e){
  console.log('Error occured ', e);
}