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

变量名和函数名同名 #50

Open
Inchill opened this issue Nov 11, 2022 · 1 comment
Open

变量名和函数名同名 #50

Inchill opened this issue Nov 11, 2022 · 1 comment

Comments

@Inchill
Copy link
Owner

Inchill commented Nov 11, 2022

@Inchill
Copy link
Owner Author

Inchill commented Nov 11, 2022

第一个链接文档中的函数 b 没有被修改为 20,是因为函数表达式标识符不可被修改,所以 b = 20 默认会失败,最后打印的 b 仍然是函数。

第二个链接文档中的变量和函数在预编译阶段存在变量提升,其中函数声明比变量声明更置顶(函数在变量上面),所以最后一次赋值后 a 不再是一个函数,执行的时候就会报错。

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