Last active
September 11, 2019 07:25
-
-
Save may88seiji/13662a9420f06d9222e1ae2b42362f2e to your computer and use it in GitHub Desktop.
配列にfor...inはダメと言うけれど、 ref: https://qiita.com/may88seiji/items/2e8fec8391fea0a17dbc
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
for(仮変数 in 連想配列){ | |
ループ内で実行する命令 | |
} |
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 data = { apple: 150, orange: 100, banana: 120}; | |
for (var key in data){ | |
console.log(key + ':' +data[key]); | |
} | |
// apple:150 | |
// orange:100 | |
// banana:120 |
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
for(仮変数 of 列挙可能なオブジェクト){ | |
ループ内で実行する命令 | |
} |
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 data = [ 'apple', 'orange', 'banana']; | |
for (var value of data){ | |
console.log(value); | |
} | |
// apple | |
// orange | |
// banana |
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 data = [ 'apple', 'orange', 'banana']; | |
for (var key in data){ | |
console.log(data[key]); | |
} | |
// apple | |
// orange | |
// banana | |
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 data = [ 'apple', 'orange', 'banana']; | |
//配列オブジェクトにhogeメソッドを追加 | |
Array.prototype.hoge = function(){} | |
for (var key in data){ | |
console.log(data[key]); | |
} | |
// apple | |
// orange | |
// banana | |
// function(){} |
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 data = [ 'apple', 'orange', 'banana']; | |
//配列オブジェクトにhogeメソッドを追加 | |
Array.prototype.hoge = function(){} | |
for (var value of data){ | |
console.log(value); | |
} | |
// apple | |
// orange | |
// banana |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment