Skip to content

fix: 1-js/06-advanced-functions/05-global-object/ #1072

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

Merged
merged 2 commits into from
Jul 3, 2022
Merged

fix: 1-js/06-advanced-functions/05-global-object/ #1072

merged 2 commits into from
Jul 3, 2022

Conversation

printfinn
Copy link
Contributor

目标章节:1-js/06-advanced-functions/05-global-object/

当前上游最新 commit:无

本 PR 所做更改如下:

文件名 参考上游 commit 更改(理由)
article.md 修改部分错误

原文: The same effect have function declarations (statements with function keyword in the main code flow, not function expressions).

原文我也提了PR, 不知道是我理解有问题还是原作者写的有问题, 感觉有语病. 可以等上游确定了在接受这里的修正.

因为前文说过var声明的函数是window的属性了, 而let/const声明的函数/变量本来也不会变成全局的属性, 那么不用var也不用let/const, 还能用函数表达式做函数声明吗? 我不是很懂这里.

@leviding
Copy link
Member

leviding commented Jul 2, 2022

因为前文说过var声明的函数是window的属性了, 而let/const声明的函数/变量本来也不会变成全局的属性, 那么不用var也不用let/const, 还能用函数表达式做函数声明吗? 我不是很懂这里.

这里是指函数声明也会使得声明的函数称为全局变量,例如:

function sayHi() {
  alert( "Hello" );
}

See: https://zh.javascript.info/function-expressions

@printfinn
Copy link
Contributor Author

因为前文说过var声明的函数是window的属性了, 而let/const声明的函数/变量本来也不会变成全局的属性, 那么不用var也不用let/const, 还能用函数表达式做函数声明吗? 我不是很懂这里.

这里是指函数声明也会使得声明的函数称为全局变量,例如:

function sayHi() {
  alert( "Hello" );
}

See: https://zh.javascript.info/function-expressions

这块我明白了, 在console里试了, 谢谢大佬哈哈! 我是感觉他后面说的“用函数表达式声明就没这种效果”有点重复. 不过这个问题不大, 谢谢!

@leviding leviding merged commit 9a130ac into javascript-tutorial:master Jul 3, 2022
@leviding leviding added DONE and removed needs +1 labels Jul 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants