I have a javascript Object obj
with the fields:
{ key1: val1,
key2: val2,
key3:
[{subkey1: subval1,
subkey2: subval2 },
{subkey3: subval3,
subkey4: subval4 }],
key4: val4
}
Now if I add a key value pair to this object,
obj.key5 = val5;
and print the obj
Object (by console.log(obj)
), it doesn't show the key5: val5
pair.
However, doing console.log(obj.key5)
does output val5
, so the key value pair is being added.
Why doesn't it show on print the whole object?
I even tried creating a duplicate object and assigning key5
to the new one, but it behaves similar to the original object.
I tried using Object.assign()
to give the same results as above.
I need to pass the obj
Object as an argument to another API, and even though obj.key5
exists, on passing it as an argument, the API doesn't read `key5'.
Thank you.