如下代码,catInstance.fn() 和 Cat.fn() 分别输出什么?
class Dog { static fn() { console.log('super zhihu') } } class Cat extends Dog { } const catInstance = new Cat(); catInstance.fn(); Cat.fn();
class Dog { static fn() { console.log('super zhihu') } } class Cat extends Dog { } const catInstance = new Cat(); catInstance.fn(); Cat.fn();
catInstance.fn() => TypeError: catInstance.fn is not a function , Cat.fn() => 'super zhihu'
catInstance.fn() => 'super zhihu' , Cat.fn() => 'super zhihu'
catInstance.fn() => undefined, Cat.fn() => TypeError: Cat.fn is not a function
catInstance.fn() => TypeError: catInstance.fn is not a function, Cat.fn() => TypeError: Cat.fn is not a function