0

I have the following javascript line:

console.log({fieldMeta__value: fieldMeta.value, fieldMeta: fieldMeta});

As you can see, I am printing to console the object fieldMeta and, also, its field value. The problem is that its field value (fieldMeta.value) returns 1, but the whole objects prints the content for value as undefined:

enter image description here

I am pretty sure I have some flaw in my logic, but I can't find it.

EDIT

I tried another approach for printing the values:

console.log(fieldMeta);
console.log(fieldMeta.value);

And I got the same result: enter image description here

HuLu ViCa
  • 5,077
  • 10
  • 43
  • 93
  • `fieldMeta__value` is just a label for `fieldMeta.value` – HuLu ViCa Nov 30 '19 at 03:10
  • Im sorry but how is this possible? :) – Ilja KO Nov 30 '19 at 03:11
  • 2
    Hover over the blue `i` and/or read https://stackoverflow.com/q/11284663/215552 – Heretic Monkey Nov 30 '19 at 03:12
  • Basically, you should use `console.dir` or `console.log(JSON.stringify(fieldMeta))` to see what the values are at the time the log occurs. – Heretic Monkey Nov 30 '19 at 03:15
  • Like the others pointed to the other SO question and the answers there: Try ```console.log(JSON.parse(JSON.stringify(fieldMeta)))``` and see if it persists – Ilja KO Nov 30 '19 at 03:18
  • @HereticMonkey I am not sure it is the same problem, because I don't change the value of the object field. I just prints different when printed individually than when printing the object as a whole – HuLu ViCa Nov 30 '19 at 03:32
  • Does it print differently if you use `JSON.stringify`? – Heretic Monkey Nov 30 '19 at 03:34
  • @HuLuViCa If you think you're not changing the value of the object field, please post a [mcve] that exhibits this behaviour. Maybe some code other than yours is changing the property. – Bergi Nov 30 '19 at 03:38

0 Answers0