I have an Object obj which has a property “value” with a value of 123. When I console.log(obj) I see firefox print the object with all its fields.
When I try to print the value of the “value” property, I get undefined.
I tried:
console.log(obj.value);
and
console.log(obj[value]);
What am I doing wrong?
If your object has got value which looks like this:
then
obj.valueandobj['value']is valid.In javascript you can use square brackets and dot notation almost interchangeably.
More information on dot vs square bracket notations