The finally block runs whether or not an error occurred. Use it for cleanup tasks like closing connections or releasing resources.
try {
openFile();
processFile();
} catch (error) {
logError(error);
} finally {
closeFile(); // Always runs
}
Finally runs even if catch throws another error.