dom*_*nos 4 javascript object-create
我总是在Firefox(3.6.14)中得到以下异常:
TypeError: Object.create is not a function
Run Code Online (Sandbox Code Playgroud)
这非常令人困惑,因为我非常确定它是一个功能,并且代码在Chrome上按预期工作.
负责此行为的代码行如下:
Object.create( Hand ).init( cardArr );
Object.create( Card ).init( value, suit );
Run Code Online (Sandbox Code Playgroud)
如果有人想看到所有代码,它来自扑克图书馆gaga.js:https://github.com/SlexAxton/gaga.js
也许有人知道如何让它在Firefox中运行?
Ale*_*yne 13
Object.create()
是EMCAScript5的新功能.遗憾的是,本机代码并没有广泛支持它.
虽然您应该能够使用此代码段添加非本机支持.
if (typeof Object.create === 'undefined') {
Object.create = function (o) {
function F() {}
F.prototype = o;
return new F();
};
}
Run Code Online (Sandbox Code Playgroud)
我相信这是来自Crockford的Javascript:The Good Parts.
归档时间: |
|
查看次数: |
3281 次 |
最近记录: |