Questions tagged «javascript-inheritance»

8
如何使用ES6类扩展Function?
Наэтотвопросестьответына 堆栈溢出нарусском:Наследованиеотфункции ES6允许扩展特殊对象。因此可以从该函数继承。可以将此类对象称为函数,但是如何实现此类调用的逻辑呢? class Smth extends Function { constructor (x) { // What should be done here super(); } } (new Smth(256))() // to get 256 at this call? 任何类方法都可通过引用类实例this。但是,当将其称为函数时,this是指window。将类实例作为函数调用时,如何获得对它的引用? PS:同样的俄语问题。
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.