回答編集履歴
1
補足の追加。
answer
CHANGED
@@ -9,4 +9,28 @@
|
|
9
9
|
for ( var i=0 ; i<2 ; i++ ) {
|
10
10
|
console.log( array[ i ]() );
|
11
11
|
}
|
12
|
-
```とか。
|
12
|
+
```とか。
|
13
|
+
|
14
|
+
---
|
15
|
+
|
16
|
+
**追記:**
|
17
|
+
|
18
|
+
下記をtest.htmlとか名前を付けてUTF-8で保存し、ブラウザで開いてみてください。
|
19
|
+
|
20
|
+
```HTML
|
21
|
+
<!DOCTYPE html><html><head><meta charset="utf-8">
|
22
|
+
<title>test_1</title>
|
23
|
+
</head><body>
|
24
|
+
<script>
|
25
|
+
function test_1(){
|
26
|
+
return 'test1';
|
27
|
+
}
|
28
|
+
function test_2(){
|
29
|
+
return 'test2';
|
30
|
+
}
|
31
|
+
for (var i = 1 ; i < 3 ; i++){
|
32
|
+
console.log( window['test_'+i]() );
|
33
|
+
}
|
34
|
+
</script>
|
35
|
+
</body></html>
|
36
|
+
```
|