From 897b8fcc1cdf5356dbcf7f0a5aa111abdad118e6 Mon Sep 17 00:00:00 2001 From: Florian Berger Date: Wed, 1 Feb 2017 18:30:47 +0200 Subject: [PATCH] Change function order in functions (7.1) example Part 7.1 says first why function declarations are not good and after that it recommends to give a name to function expression. The same order could be used in example too. --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 775fc6fb..ec99a55e 100644 --- a/README.md +++ b/README.md @@ -579,16 +579,16 @@ Other Style Guides > Why? Function declarations are hoisted, which means that it’s easy - too easy - to reference the function before it is defined in the file. This harms readability and maintainability. If you find that a function’s definition is large or complex enough that it is interfering with understanding the rest of the file, then perhaps it’s time to extract it to its own module! Don’t forget to name the expression - anonymous functions can make it harder to locate the problem in an Error's call stack. ([Discussion](https://github.com/airbnb/javascript/issues/794)) ```javascript - // bad - const foo = function () { - // ... - }; - // bad function foo() { // ... } + // bad + const foo = function () { + // ... + }; + // good const foo = function bar() { // ...