この文書の現在のバージョンと選択したバージョンの差分を表示します。
javascript:関数オブジェクトforeach [2019/02/08 06:43] ips 作成 |
javascript:関数オブジェクトforeach [2019/02/08 06:48] (現在) ips |
||
---|---|---|---|
ライン 1: | ライン 1: | ||
====== 関数オブジェクトforeach ====== | ====== 関数オブジェクトforeach ====== | ||
+ | <code> | ||
+ | <!DOCTYPE html> | ||
+ | <html> | ||
+ | <body> | ||
+ | |||
+ | <script type="text/javascript"> | ||
+ | var data=new Array(); | ||
+ | data.push(0); | ||
+ | data.push(1); | ||
+ | data.push(2); | ||
+ | data.forEach(function(val,index,ary){ | ||
+ | console.log(ary[index]); // 0,1,2と順番に表示される | ||
+ | }); | ||
+ | </script> | ||
+ | </body> | ||
+ | </html> | ||
+ | </code> | ||