Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yeah, it gets really hairy, really quickly.

Beyond the need for calling the constructor (which I'm currently viewing it as an unnecessary hidrance [objects are already initialized]), Object.getPrototypeOf may provide a way out - but maybe not the way you intended. Have you considered it?



    Object.getPrototypeOf(Child).constructor.apply(this, arguments);
Works, but is even more verbose. However if you use Object.getPrototypeOf on this you fail the recursive problem in nest super calls. Read the stackoverflow euestion


I was deliberately excluding the constructor situation. I should have made that clearer in my previous comment. I think the way out of the constructor mess is not to require them at all.

I do think the Object.getPrototypeOf approach is feasible for methods.


the method fails for the exact same reason.

If a single method calls a super method and that method calls another super method then it fails.

    Object.getPrototypeOf(this).method
Always have one value and only one value, calling it more then once leads to infinite recursion.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: