我想使用实例访问静态属性。这样javascript:如何访问静态属性
function User(){
console.log('Constructor: property1=' + this.constructor.property1) ;
}
User.prototype = {
test: function() {
console.log('test: property1=' + this.constructor.property1) ;
}
}
User.property1 = 10 ; // STATIC PROPERTY
var inst = new User() ;
inst.test() ;
的东西在这里是在jsfiddle
在我的情况,我不知道该实例属于哪个类相同的代码,所以我试图用实例来访问静态属性的构造函数“属性,但没有成功:( 这可能吗?
不要在javascript中使用word类 – 2013-05-02 18:20:24
@Johan:这个链接怎么和这里的任何东西相关? – Bergi 2013-05-02 18:28:48