TS / JS самообучающийся класс - PullRequest
0 голосов
/ 18 октября 2019

Возможно ли выполнить код после наследования родительского класса? Устранение необходимости инициализировать дочерний класс.

После того, как я возился с собой и провел неделю поисков, я вышел пустым.

    // This works, its will add the class in the registry array

    let registry = [];

    class Parent {
        constructor() { 
            registry.push(this) 
        }
    }

    class Child extends Parent {

    }

    let child = new Child();



    // What i wish i could do, note that the final line of code is removed. 
    // Removing the line stops the program from adding the class to the array,  
    // is it possible to achieve the same result as above without that line?

    let registry = [];

    class Parent {        
        constructor() { 
            registry.push(this) 
        }
    }

    class Child extends Parent {

    }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...