For concise methods, the problem is already solved by 'this',
isn't it?
({f(n){return n>1?n*this.f(n-1):1}}.f)(6)
720
No, not for the general case. You could have arrived here via a 'super' method call in which case
'this.f' will take you back to a subclass' f rather then recurring on this specific function
Sometimes, this might be what you want in such a case. If it isn't,
then how about:
class Super { f(n) {return n>1?n*Super.prototype.f(n-1):1 }}
class Sub extends Super { f(n) { return 1+super.f(n) }};
console.log((new Sub()).f(5)); // 121, rather than 326
Claus
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss