JavaScript, 62 61 37 bytes
Thanks to @Doᴡɴɢᴏᴀᴛ for the help!
Original [37 bytes]:
f=_=>'f='+'_'.repeat((10+f).length)+f
Child [74 bytes]:
f=______________________________________=>'f='+'_'.repeat((10+f).length)+f
Grandchild [148 bytes]:
f=________________________________________________________________________________________________________________=>'f='+'_'.repeat((10+f).length)+f
Alternate (with printing to console, and as a full program):
Original [61 bytes]:
f=_=>console.log(`f=${'_'.repeat((0+f).length+5)+f};f()`);f()
Child [122 bytes]:
f=______________________________________________________________=>console.log(`f=${'_'.repeat((0+f).length+5)+f};f()`);f()
Grandchild [244 bytes]:
f=________________________________________________________________________________________________________________________________________________________________________________________=>console.log(`f=${'_'.repeat((0+f).length+5)+f};f()`);f()
How it works!
1. f=_=>
Define function f as console.log(...)
2. ;f()
Run function f.
3. (in function f)
Notes
console.log
is necessary instead of alert
because alert
doesn't seem to play well with really long strings (at least on my machine/browser configuration)
- The
_
's are inserted into the name of the (unused) parameter of function f, to ensure that they are included in the stringification of f.
- Main improvement (aside from getting rid of the
console.log
) of the first solution over the second: adding 10
to the function instead of 0
to cast it to string makes it one byte longer, eliminating the need to add 1 to the length afterwards, saving a byte.