logoalt Hacker News

troupo • 04/01/2025 • 1 reply • view 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

joquarky • 04/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