Created
June 20, 2011 06:21
-
-
Save ohnishiakira/1035198 to your computer and use it in GitHub Desktop.
JavaScriptのfor文の書き方
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ary = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; | |
// 普通の書き方 | |
for (var i = 0; i < 10; i++) { console.log(ary[i]); } | |
// こう書くとループ内がシンプルになる。その分 for (...) の部分が長くなるけど。 | |
for (var i = 0, a = 0; i < 10; i++, a = ary[i]) { console.log(a); } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment