gpt4 book ai didi

javascript - IE8 `window.fn !== fn`

转载 作者:可可西里 更新时间:2023-11-01 02:21:46 27 4
gpt4 key购买 nike

谁能解释一下? IE8

( function(){
window.foo = function foo(){};
console.log( window.foo === foo ); // false
}() );

最佳答案

由于 IE 错误,命名函数表达式创建了一个单独的本地 foo 变量,其中包含函数的单独副本。

More info :

var f = function g(){};
f === g; // false

This is where things are getting interesting. Or rather — completely nuts. Here we are seeing the dangers of having to deal with two distinct objects — augmenting one of them obviously does not modify the other one; This could be quite troublesome if you decided to employ, say, caching mechanism and store something in a property of f, then tried accessing it as a property of g, thinking that it is the same object you’re working with.

关于javascript - IE8 `window.fn !== fn`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8647920/

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