Backbencher.dev

JS Daily 17 - Non Existent Object Property

Last updated on 7 Dec, 2020

What is the output of following code?

const obj = {
  name: "Backbencher"
}
console.log(obj.age);
----o----

The output is undefined.

obj is an object literal. We are trying to access the value of a property that is not present in obj. It results in undefined.

--- ○ ---
Joby Joseph
Web Architect