これはいいまとめ。目新しいものがあるわけじゃないのに、なぜかこういう記事を読むのは楽しいですね😊
JavaScript過去10年間に進化した項目のまとめ
配列関数
- Array.every()
- Array.filter()
- Array.find()
- Array.findIndex()
- Array.forEach()
- Array.from()
- Array.includes()
- Array.isArray()
- Array.lastIndexOf()
- Array.map()
- Array.reduce()
- Array.reduceRight()
- Array.some()
const/let
?? / ?.
async / awaitキーワード
arrow function ()=> {}
for...of / for await...of
クラス
setter/getter
デストラクチャリング
代入演算子=
の左側で {}
や []
を使うことで、オブジェクトや配列から値を抜き出して変数に格納する処理を一行で書ける
const obj = {state: {id: 1, is_verified: false}}
const {id, is_verified: verified} = obj.state
関数のデフォルトパラメータ
名前付きパラメータ
デストラクチャリングと関数デフォルトパラメータの組み合わせ。
function greet({name = "Jane", age = 42} = {}){
print(name + " " +age)
}
greet()
greet({name: "John", age: 21})
restパラメータ
...
で可変長引数を表現できる
function greet(msg1, ...msgs) {
}
Object.assignおよびspread演算子
ショートハンド関数(もしくはメソッド)
オブジェクトで宣言された関数は、functionキーワードを省略した新しい省略形を使用できる。
const x = {
type: "x",
shorthand() {
print("shorthand "+this.type)
},
long: function() {
print("long "+this.type)
}
}
x.shorthand()
x.long()
Promiss.all
非同期処理を並列実行するのに便利。
テンプレート文字列リテラル
プロキシ
モジュール(import/export)
などなど。詳しくは原文を御覧ください!
https://turriate.com/articles/modern-javascript-everything-you-missed-over-10-years
Google翻訳版: https://translate.google.com/translate?sl=en&tl=ja&u=https%3A%2F%2Fnews.ycombinator.com%2Fitem%3Fid%3D27165954