Editor Arrow Download Open
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Throw Statement with Error constructor</title> </head> <body> <script> var x = 10, y = 10; try { if(x == y) throw new Error("Exception: Both are same value!"); else throw new Error("Exception: Both are different!"); } catch(e) { alert(e.message); } </script> </body> </html>
  Preview Arrow