> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Avoid-Function-Declarations-In-Blocks

#### Sourcery rule id: `avoid-function-declarations-in-blocks`

#### Description

Avoid function declarations, favouring function assignment expressions, inside blocks.


#### Match

```javascript
if (x) {
  function foo() {}
}
```



#### Explanation

Function declarations may be hoisted in Javascript, but the behaviour is inconsistent between browsers.
Hoisting is generally confusing and should be avoided. Rather than using function declarations inside blocks, you
should use function expressions, which create functions in-scope.
