Closed
Description
- Version: 8.5.0
- Platform: Windows 7 x64
- Subsystem: util
I am trying to make a simple object autovivification with Proxy:
function autoVivify() {
return new Proxy({}, {
get(target, property) {
if (target[property] === undefined) target[property] = autoVivify();
return target[property];
},
});
}
const obj = autoVivify();
obj.a.b.c = 1;
console.log(obj);
{ a:
{ b: { c: 1, [Symbol(util.inspect.custom)]: [Object] },
[Symbol(util.inspect.custom)]: { [Symbol(util.inspect.custom)]: [Object] } },
[Symbol(util.inspect.custom)]: { [Symbol(util.inspect.custom)]: { [Symbol(util.inspect.custom)]: [Object] } } }
I understand that this is an edge case and maybe the output is correct. But I feel somehow that I should report this in case it is not completely intended. Feel free to close if it is by design.