IE8 getPrototypeOf方法 [英] IE8 getPrototypeOf method

查看:251
本文介绍了IE8 getPrototypeOf方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很简单:

我有代码使用 Object.getPrototypeOf(...)获取继承一个Dojo小部件的类(只是一个JS对象)。 IE8不支持 Object.getPrototypeOf(...)。我需要一个IE工作。有任何想法吗?感谢提前。

I have code using Object.getPrototypeOf(...) to get the inherited classes of a Dojo Widget (just a JS object). Object.getPrototypeOf(...) isn't supported in IE8. I need an IE work around. Any ideas? Thanks in advance.

推荐答案

Jon Resig的polyfill作品
http://ejohn.org/blog/objectgetprototypeof/

Jon Resig's polyfill works http://ejohn.org/blog/objectgetprototypeof/

我已经使它更小p>

I have made it even smaller

if (typeof Object.getPrototypeOf !== "function")
    Object.getPrototypeOf = "".__proto__ === String.prototype
        ? function (object) {
            return object.__proto__;
        }
        : function (object) {
            // May break if the constructor has been tampered with
            return object.constructor.prototype;
        };

这篇关于IE8 getPrototypeOf方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆