finally Block

noun

say it: “FY-nuh-lee blok” /ˈfaɪnəli blɑk/

The part of a try statement, written finally { }, that runs after the try and catch blocks whether anything failed or not, often to tidy up.

What is finally Block in JavaScript?

finally Block — A block that normally runs after try and catch whether an exception occurred or not.

function reserve(seats) {
    if (seats < 1) {
        throw new Error("Seat count must be positive");
    }
}

In a sentence

  • “The Loading message is hidden in the finally block, so it goes away whether the order saved or failed.”
  • “I turned the Search button back on in the finally block, so it never stays stuck off.”
  • “The finally block hides the "Loading..." message, whether the photo arrived or not.”

Level: Journeyman · More JavaScript terms at this level

Updated

In other subjects