Skip to content

Commit

Permalink
js 函数声明
Browse files Browse the repository at this point in the history
  • Loading branch information
realgeoffrey committed Sep 2, 2024
1 parent c2b503a commit 8128340
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions 网站前端/JS学习笔记/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,9 @@
2. 函数声明
1. 也会被JS引擎提升到当前执行的作用域顶部声明(函数声明就等同于赋值),因此代码中函数的调用可以出现在函数声明之前。
2. 函数声明不应当出现在~~语句块~~内(如:条件语句),语句块的函数也会提前声明,导致语义不清容易出错
2. 函数声明不应当出现在~~语句块~~内(如:条件语句),块内函数声明的行为很奇怪,请勿使用它们
>在非严格模式下,块内函数声明的行为很奇怪。请勿使用它们。在严格模式下,块内函数声明仅在块内作用域中 或 不允许
>在非严格模式下,语句块的函数也会提前声明,导致语义不清容易出错;在严格模式下,块内函数声明仅在块内作用域中(或 不允许块内函数声明)
3. 函数表达式(Function expressions)声明
必须先声明:`var a = function () {...};`才可以使用,`a`声明会被提前,但`a`赋值不会被提前。
Expand Down

0 comments on commit 8128340

Please sign in to comment.