-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
部分问题纠正 #128
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
单行的for和if可以不使用大括号,使代码更简洁(这个其实看团队代码风格)
关于闭包的文章几乎都是抄来抄去,人云亦云,然而自己根本就不理解。这里的回答也是, 强调“函数里嵌套函数”,或者“有权访问”另一个函数的作用域,可以说并没有理解到闭包的本质。
可以说,一切函数都是闭包, 看下面这个例子:
执行run()的时候,打印的值是0,正是因为getCount函数是"闭包",包含了函数本身和其外部变量(或者说作用域链)。
详细内容可以看我的博客
或者MDN上的内容(闭包|MDN)
str并没有parseJSON方法,obj也没有toJSONString方法。
这个例子并没有指出call/apply的关键,即修改this指向
The text was updated successfully, but these errors were encountered: