For example, given this object:
let foo = {foo:1};
let bar = {a:foo,b:foo};
We can define bar as a single expression by writing it as:
let bar = (($0)=>({a:$0={foo:1},b:$0}))()
However, given this object:
let o = {a:'perfect'};
o.circle = o;
Is it possible to recreate the structure of o with a single expression?
This won't work:
(($0)=>($0={a:"perfect",circle:$0}))()
Because circle is nested and $0 has been defined yet.
Object.assign()be able to do what you want? I feel like it might.({...$0={a:'perfect'},circle:$0}). UseObject.assignas necessary. I really don't see why you need this.{a:'perfect',circle:{a:'perfect'}}circlealso in thecircleproperty?Object.assign($0={a:'perfect'}, {circle:$0})could do that.