Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

浏览器的奇葩行为--IE8 #4

Open
jackytedy opened this issue May 3, 2014 · 0 comments
Open

浏览器的奇葩行为--IE8 #4

jackytedy opened this issue May 3, 2014 · 0 comments

Comments

@jackytedy
Copy link
Owner

//ie8使用的5.8版本--混淆了命名函数表达式
//[函数表达式标识符渗透到作用域中(enclosing)
//命名函数表达式标识符在某外部作用域中是无效的。---Jscript明显违反该规定。下面的g被解析为函数对象。这样标识符就可能不经意的污染某个外部作用域--甚至是全局作用域。

var f = function g() {};
typeof g;   // "function"

//将命名函数表达式同时当作函数声明和表达式
//<--函数声明优先于任何表达式被解析-->

typeof g; // function
var f = function g(){}; //Jscript实际上是把函数表达式当作函数声明了。

//命名函数创建两个不同对象
var f = function g(){};
f === g

f.expando = 'foo';
g.expandol // undefined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant