回答編集履歴
2
test
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
array.forEach(e => console.log(e));
|
4
4
|
```
|
5
5
|
|
6
|
-
は下記
|
6
|
+
は下記のような形でも書けます。
|
7
7
|
|
8
8
|
```js
|
9
9
|
const array = [0, 1, 2, 3, 4];
|
1
test
CHANGED
@@ -1,36 +1,31 @@
|
|
1
|
-
```
|
1
|
+
```js
|
2
2
|
const array = [0, 1, 2, 3, 4];
|
3
|
-
|
4
3
|
array.forEach(e => console.log(e));
|
5
4
|
```
|
6
5
|
|
7
|
-
は下記と同じ
|
6
|
+
は下記と同じような動作になります。
|
8
7
|
|
9
|
-
```
|
8
|
+
```js
|
10
9
|
const array = [0, 1, 2, 3, 4];
|
11
|
-
|
12
10
|
function printArray(e) {
|
13
11
|
console.log(e);
|
14
12
|
}
|
15
|
-
|
16
13
|
array.forEach(printArray);
|
17
14
|
```
|
18
15
|
|
19
16
|
|
20
|
-
```
|
17
|
+
```js
|
21
18
|
const array = [0, 1, 2, 3, 4];
|
22
|
-
|
23
19
|
const printArray = (e) => {
|
24
20
|
console.log(e);
|
25
21
|
}
|
26
|
-
|
27
22
|
array.forEach(printArray);
|
28
23
|
```
|
29
|
-
「forEach関数の引数として、printArrayという関数が渡されている」
|
24
|
+
「forEach関数の引数として、printArrayという関数が渡されている」。
|
30
25
|
なので、printArray はコールバック関数です。
|
31
26
|
|
32
27
|
関数に、printArrayという具体的な名前を付ける代わりに
|
33
28
|
「e => console.log(e)」という形でも書ける、というだけです。
|
34
29
|
|
35
|
-
この「e => console.log(e)」自体も関数
|
30
|
+
この「e => console.log(e)」自体も関数であり、引数として渡されているので、コールバック関数です。
|
36
31
|
|