Skip to main content

Matt Smith

  • About
  • Contact
Web Dev | Front-End Engineer | UX Designer

Default parameters: your code just got smarter

2 min read
925 views

Whether you’re building UI components, calling APIs, or writing some utility functions, it’s quite common to deal with optional function arguments. Traditionally, you’d fall back on if statements or logical ORs to assign default values. But let’s be honest, that can lead to subtle bugs. How often have you written...

  • JavaScript
  • React

Using await at the top level in ES modules

2 min read
4510 views

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, a modern ES module feature that enables new patterns for asynchronous code at the module level. What’s top-level await? Traditionally await...

  • JavaScript

Write more reliable JavaScript with optional chaining

2 min read
3567 views

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 This is a common pain point, especially when working with API responses, optional fields,...

  • JavaScript
  • React
Newer posts Older posts
Twitter
LinkedIn
GitHub
CodePen
© 2025 Matt Smith. All rights reserved.