简体   繁体   English

IE9将上下文“ this”转换为对象

[英]IE9 cast context 'this' to Object

I've found out strange behavior in IE9. 我发现IE9中有奇怪的行为。 Lets say we have a function that return context: 可以说我们有一个返回上下文的函数:

function toContext() { return this; }

In IE9, if I call it with some primitive context, the context is casted to Object 在IE9中,如果我使用一些原始上下文进行调用,则该上下文将转换为Object

toContext.call(3);  // => [object Number]
toContext.call(""); // => [object String]

In IE10 and later, it returns passed primitive, but IE9 gives this strange results, which spoils my coding pattern. 在IE10及更高版本中,它返回传递的原语,但IE9给出了这种奇怪的结果,这破坏了我的编码模式。

I emulate IE9 in IE11, maybe this is problem with a emulation. 我在IE11中模拟IE9,也许这是一个模拟问题。 I searched for this behavior of old IE, but found nothing usefull. 我搜索了旧IE的这种行为,但没有发现任何有用的信息。 Can someone confirm that this behavior affects native IE9 or maybe someone know more about this topic? 有人可以确认此行为会影响本机IE9,还是有人可以进一步了解此主题?

IE9不支持严格模式 ,你似乎可以用,但要得到原始的this值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM