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
.