想我需要声明一些私人静态成员在一些公共静态方法来使用它...声明一个JavaScript类
// ***** Variant I *****
function supports() {
var impl = document.implementation; // private, non-static
this.SVG = function() { // public, non-static
return impl.hasFeature("http://www.w3.org/TR/SVG11/feature#Image", "1.1");
};
}
// ***** Variant II *****
function supports() { }
supports.prototype.impl = document.implementation; // public, non-static
supports.SVG = function() { // public, static
return impl.hasFeature("http://www.w3.org/TR/SVG11/feature#Image", "1.1");
};
我内公开的“静态”功能知道JavaScript与'静态'OOP概念有一些困难,所以我的问题是:
我可以声明公共静态方法里面“对象”的“声明主体”(如上面的“变体I”)?
'supports.prototype.impl = ...' - **公共非静态**(成员) – hindmost
@hindmost:感谢校正!我相应地修复了注释 – Serge