bind polyfill for PhantomJS

做~自己de王妃 提交于 2019-11-28 14:04:07

I tried the polyfill in this link and it seems to work fine for me.

Note that phantomjs scripts run inside WebKit's JavaScriptCore engine (which uses ES5) so most of these functions should already come out of the box.

D:\>phantomjs.exe

phantomjs> console.log(Object.keys)
function keys() {
    [native code]
}
undefined

phantomjs> var shim = require("D:\\es5-shim.js");
undefined

phantomjs> console.log(Object.keys)
function keys(object) {
        if (isArguments(object)) {
            return originalKeys(ArrayPrototype.slice.call(object));
        } else {
            return originalKeys(object);
        }
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!