Skip to main content

Matt Smith

  • About
  • Elsewhere
Modern Web Engineering, Front-End First

Using await at the top level in ES modules

2 min read

Writing asynchronous code in JavaScript used to come with a limitation: the await keyword could only be used inside an async function. That changed when ES2022 introduced top-level await, which lets you use await at the top of an ES module. What’s top-level await? Traditionally await was only valid inside...

  • JavaScript

Write more reliable JavaScript with optional chaining

2 min read

Let me know if this sounds familiar: you’re deep into debugging or trying to access a deeply nested property in a JavaScript object. Suddenly you see this classic error: TypeError: Cannot read property 'x' of undefined It happens a lot with API responses, optional fields, and dynamic data. JavaScript has...

  • JavaScript
  • React

How JavaScript’s at() method makes array indexing easier

1 min read

Arrays are an everyday thing for front-end developers: rendering lists, managing state, juggling DOM elements. Getting the last item has always been clunkier than it should be. Array.prototype.at() makes it easy. What’s at()? The at() method is a relatively new addition to JavaScript (introduced in ECMAScript 2022), and it’s designed...

  • JavaScript
Older posts Newer posts
GitHub
LinkedIn
CodePen
RSS
© 2026 Matt Smith. All rights reserved.