Skip to content

Commit 32f60ab

Browse files
committed
var statements at the start of their respective scope with examples
1 parent abbc78b commit 32f60ab

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

readme.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,27 @@ Projects _must_ include some form of unit, reference, implementation or function
198198
foo = "",
199199
bar = "",
200200
quux;
201+
202+
// 2.B.1.3
203+
// var statements should always be in the beginning of their respective scope (function).
204+
// Same goes for const and let from ECMAScript 6.
201205

206+
// Bad
207+
function foo() {
208+
209+
// some statements here
210+
211+
var bar = "",
212+
qux;
213+
}
214+
215+
// Good
216+
function foo() {
217+
var bar = "",
218+
qux;
219+
220+
// all statements after the variables declarations.
221+
}
202222
```
203223

204224
```javascript

0 commit comments

Comments
 (0)