3 ms·
I’ve been programming for ~15 years, including the last 5 years professionally in JavaScript, and I’ve yet to use a `finally`. Am I alone in this, or is it real
by TechBro8615 5y ago
I’ve been programming for ~15 years, including the last 5 years professionally in JavaScript, and I’ve yet to use a `finally`. Am I alone in this, or is it really meant for niche use cases?
- moltar 5y agoIt’s pretty common, but small surface of application. The two most common use cases I’ve seen so far: 1. Same as the article example. UI action when AJAX request completes 2. In NodeJS disconnecting from resources (db, redis) after you are done. Otherwise the script will hang and never exit.
- paulddraper 5y agoBackend code has uses for it. Like closing/releasing a database connection.
- chrisseaton 5y agoHow do you ensure that a resource you are using will be released if there is an exception somewhere in your code?