[英]Inheritance of static class properties
Static class properties are inherited: Static class 属性被继承:
const foo = class { static prop = 'this is a static prop' } const bar = class extends foo {} console.log(bar.prop) // 'this is a static prop'
But I thought static properties were akin to the following, which prints undefined
as expected:但我认为 static 属性类似于以下内容,它按预期打印undefined
:
const foo = function() {} foo.prop = 'this is a static prop' const bar = function() {} bar.prototype = Object.create(foo.prototype) bar.prototype.constructor = bar console.log(bar.prop) // undefined
So is static class property inheritance magical behavior provided over and above ordinary prototypical inheritance? static class 属性 inheritance 提供的神奇行为超出了普通原型 Z5FED3411FAF2032174EF1F042?C
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.