mirror of
https://github.com/airbnb/javascript.git
synced 2026-01-14 21:18:24 -05:00
@@ -255,7 +255,7 @@
|
||||
```
|
||||
|
||||
- Never declare a function in a non-function block (if, while, etc). Assign the function to a variable instead. Browsers will allow you to do it, but they all interpret it differently, which is bad news bears.
|
||||
- **Note:** ECMA-262 defines a `block` as a list of statements. A function declartion is not a statement. [Read ECMA-262's note on this issue](http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf#page=97).
|
||||
- **Note:** ECMA-262 defines a `block` as a list of statements. A function declaration is not a statement. [Read ECMA-262's note on this issue](http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf#page=97).
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -454,7 +454,7 @@
|
||||
var declaredButNotAssigned = true;
|
||||
}
|
||||
|
||||
// The interpretor is hoisting the variable
|
||||
// The interpreter is hoisting the variable
|
||||
// declaration to the top of the scope.
|
||||
// Which means our example could be rewritten as:
|
||||
function example() {
|
||||
|
||||
Reference in New Issue
Block a user