On Chrome's and Node's console, I assigned the property of an object to have the value of undefined
.
const foo = {
bar: undefined
};
When I evaluate foo
again, I expected it to give me an empty object ({}
), but it returns with:
{
bar: undefined
}
Are there any differences between { bar: undefined }
and {}
?
The reason I am asking is that this difference is failing my tests - I am expecting the result to be {}
, but it's failing because the actual response is { bar: undefined }
.
If it was { bar: null }
I'd understand, since null
is an actual value. But my understanding is that undefined
means the property is undefined and thus not even a value.