JavaScript/Reserved words/finally

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

The finally keyword[edit | edit source]

The finally keyword is used as clause of the try statement.

Examples[edit | edit source]

Crystal Clear action apply.png The code
  var result;

  try {
    result = log(-12.05);
    alert("Executed comment successfully.");
  } catch(err) {
    document.getElementById("demo").innerHTML = err.message;
  } finally {
    alert("result = " + result); // This line will execute anyway
(Will add to the HTML element called "demo" the error message.)
result = undefined

See also[edit | edit source]

Previous: final Reserved words Next: float