ECMAScriptの仕様改定に伴うJavaScriptの新しい文法.var句,function句,配列表示を使わなくなれる代わりに,const/let句,アロー演算子,for of句を使う.また,async/await句が導入され,非同期処理が簡単にできる.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Demo - For of</title> <script> const i = [10, 20, 30]; const for_of = async () => { for(let v of i){ await document.writeln(v); } } const map_for_of = async () => { const m = new Map([ ['A', 'K'], ['J', 'Q'] ]); for(let [k, v] of m){ await document.writeln(`${k} : ${v}`); } } </script> </head> <body> <button onclick="for_of()">For of</button> <button onclick="map_for_of()">Map</button> <button onclick="for_of(); map_for_of()">Async</button> </body> </html>