Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
experiment
> class F {
... constructor (a) {
..... if (a > 0) {
....... this.child = new F(a-1)
....... }
..... }
... }
undefined
> new F(3)
F { child: F { child: F { child: F {} } } }
> new F(8)
F { child: F { child: F { child: [F] } } }
> var f = new F(8)
undefined
> f.child
F { child: F { child: F { child: [F] } } }
> f.child.child.child.child
F { child: F { child: F { child: [F] } } }
> f.child.child.child.child.child
F { child: F { child: F { child: F {} } } }
> f.child.child.child.child.child.child
F { child: F { child: F {} } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment