logoalt Hacker News

troupo04/01/20251 replyview on HN

Nothing in your view is "web standards". And nothing in web standards can do the heavy lifting of showing things like "`nam` is not defined on object `user`"


Replies

joquarky04/02/2025

  if (!user || typeof user.nam !== 'string') {
    throw new Error("Missing or invalid 'nam' on user");
  }
Contemporary JavaScript has optional chaining, default values, and reflective tools like Object.hasOwn, which are all web standards. You just have to know how to use them.
show 1 reply