You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/rules/init-declarations.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,8 +7,8 @@ rule_type: suggestion
7
7
In JavaScript, variables can be assigned during declaration, or at any point afterwards using an assignment statement. For example, in the following code, `foo` is initialized during declaration, while `bar` is initialized later.
8
8
9
9
```js
10
-
var foo =1;
11
-
var bar;
10
+
let foo =1;
11
+
let bar;
12
12
13
13
if (foo) {
14
14
bar =1;
@@ -22,8 +22,8 @@ if (foo) {
22
22
This rule is aimed at enforcing or eliminating variable initializations during declaration. For example, in the following code, `foo` is initialized during declaration, while `bar` is not.
23
23
24
24
```js
25
-
var foo =1;
26
-
var bar;
25
+
let foo =1;
26
+
let bar;
27
27
28
28
bar =2;
29
29
```
@@ -109,7 +109,7 @@ function foo() {
109
109
var bar =1;
110
110
let baz =2;
111
111
112
-
for (var i =0; i <1; i++) {}
112
+
for (let i =0; i <1; i++) {}
113
113
}
114
114
```
115
115
@@ -141,7 +141,7 @@ Examples of **correct** code for the `"never", { "ignoreForLoopInit": true }` op
0 commit comments