gpt4 book ai didi

javascript - IE8 getPrototypeOf 方法

转载 作者:行者123 更新时间:2023-11-28 07:31:43 25 4
gpt4 key购买 nike

非常简单:

我有代码使用Object.getPrototypeOf(...)来获取Dojo Widget的继承类(只是一个JS对象)。 IE8 不支持 Object.getPrototypeOf(...)。我需要一个 IE 解决方案。有任何想法吗?提前致谢。

最佳答案

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

我把它做得更小了

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;
};

关于javascript - IE8 getPrototypeOf 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29058683/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com