Loading…
A short voice session: one question, one follow-up, then instant feedback — up to 5 minutes.
Dot access uses a fixed property name; bracket access can use a computed key. Object.hasOwn checks an object's own properties.
user.name reads the property literally named name. user[key] uses the value of key, so const key = "name" selects the same property. Brackets also support names such as "first-name". Object.hasOwn(user, "name") checks an own property, while "name" in user also considers inherited properties. A missing property normally reads as undefined, which alone cannot distinguish missing from an own property whose value is undefined.