Skip to main content

Matt Smith

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

When to use map() vs. forEach()

1 min read
3406 views

I saw this post on Reddit about a JavaScript coding assessment and it got me thinking. A common task developers perform is iterating over arrays. And two of the most frequently used methods for this are map() and forEach(). Both seem similar, but the differences can significantly affect how your...

  • JavaScript

Mastering default values in JavaScript with the nullish coalescing (??) operator

1 min read
5049 views

One piece of JavaScript syntax I’ve come to appreciate is the nullish coalescing (??) operator. It’s one of those features that’s easy to overlook until it saves you from a subtle bug. If you’re still using the logical OR (||) operator to provide default values, it’s worth knowing where the...

  • JavaScript

Leveraging “unknown” instead of “any”

1 min read
739 views

One habit I’ve picked up over the years using unknown as a default before any. I still use any occasionally, but I’ve become much more intentional about it. The reason is pretty simple: any opts you out of TypeScript’s type checking. That can be convenient when you’re prototyping or working...

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