Imagine you have this object:
var o = { a: "property 1", b: "property 2", c: "property 3", d: "property 4", p: "property 5" }
and do the following:
for (p in o) { console.log(op); }
the result will be:
property 5 property 5 property 5 property 5 property 5
Because op means you want to get the value of a property named p .
Similarly, in your example, the p property is not defined in your object.
If you want to get the value of a property using a string , you must use the notation [] .
source share