JavaScript/Reserved words/catch

From Wikibooks, open books for an open world
Jump to navigation Jump to search
Previous: case Reserved words Next: char

The catch keyword[edit | edit source]

The catch keyword is used as part of the try statement.

Examples[edit | edit source]

The code
  try {
    log(-12.05);
    alert("Executed comment successfully.");
  } catch(err) {
    document.getElementById("demo").innerHTML = err.message;
  }
</script>
(Will add to the HTML element called "demo" the error message.)


See also[edit | edit source]

Previous: case Reserved words Next: char