快捷导航

求解释下面js中的枚举类型的代码是什么意思?

functioninherit(p){                if(p==null)throwTypeError();                if(Object.create)returnObject.create(p);                vart=typeofp;                if(t!=="object"&&t!=="function")throwTypeError();                functionf(){};                f.prototype=p;                returnnewf();        }        functionenumeration(namesToValues){                varenumeration=function(){throw"can'tinstantiateenumeration"};                varproto=enumeration.prototype={                        constructor:enumeration,                        toString:function(){returnthis.name;},                        valueOf:function(){returnthis.value;},                        toJSON:function(){returnthis.name;}                };                enumeration.values=[];                for(nameinnamesToValues){                        vare=inherit(proto);                        e.name=name;                        e.value=namesToValues[name];                        enumeration[name]=e;                        enumeration.values.push(e);                }                enumeration.foreach=function(f,c){                        for(vari=0;i

免责声明:本内容仅代表回答者见解不代表本站观点,请谨慎对待。

版权声明:作者保留权利,不代表本站立场。

回复

使用道具 举报

可能感兴趣的问答

发新帖
TA的信息
  • 会员所属: 注册会员
  • 认证信息: 邮箱认证手机认证
  • 微信访问
  • 手机APP