Digging into JavaScript's `finally`: Completion Records, Flow Control Pitfalls, and the Road to `using`

Saw an interesting question pop up in a Discord server the other day that reminded me of a classic JavaScript head-scratcher: what really happens when you use flow control statements like return or throw inside a finally block? Most of us use try...catch...finally regularly, especially finally for crucial cleanup tasks: closing file handles, releasing network connections, resetting state, you name it. Its guarantee to run, whether the try block succeeds, fails (throw), or exits early (return), is fundamental. ...

September 8, 2023 · 7 min · 1409 words · Dennis Lin

ESM in the Wild: Field Notes from the JavaScript Module Transition

Libraries are shifting to ESM-only, build tools reveal sharp edges, and mixed ecosystems introduce subtle incompatibilities. This post offers a technically grounded snapshot of challenges and emerging patterns during this transitional phase, based on my hands-on experience and community input. How We Got Here JavaScript’s module story has been… complicated. In the early days, all JavaScript code lived in the global scope. Developers relied on naming conventions and immediately invoked function expressions (IIFEs) to prevent collisions. Then Node.js came along with CommonJS, giving us require() and module.exports. Finally, in 2015, ECMAScript 6 introduced native modules with import and export statements. ...

August 20, 2022 · 7 min · 1427 words · Dennis Lin

Towards Better Date Handling in JavaScript: An Exploration to the Temporal API Proposal

JavaScript has come a long way in terms of language features, but one area that has notoriously lagged behind is date and time handling. The ECMAScript Date object has been a source of confusion and frustration due to its inconsistent behaviors, mutability, tricky timezone handling, and limitations. This leaves many developers relying on third-party libraries to perform even fundamental date calculations. Fortunately, we have champions who are well-versed of these challenges, leading to the Temporal API proposal. Having reached Stage 3 in the ECMAScript standardization process, Temporal offers a modern, robust, and ergonomic alternative for working with dates, times, time zones, and durations. ...

February 26, 2022 · 4 min · 806 words · Dennis Lin