Skip to main content

Matt Smith

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

Default parameters: your code just got smarter

June 29, 2025
2 min read
0 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

June 16, 2025
2 min read
3647 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

June 2, 2025
2 min read
3262 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
Older posts
Twitter
LinkedIn
GitHub
CodePen
© 2025 Matt Smith. All rights reserved.