配列とかおれおれAdvent Calendar2018 – 18日目 ありそうでないメソッド、それが重複排除です。 Underscore.jsやLodashには uniq() てのがあって、こんな感じ↓で使えます。
![配列で重複する項目を取り除くやつ4種。(配列とかおれおれAdvent Calendar2018 – 18日目) | Ginpen.com](https://cdn-ak-scissors.b.st-hatena.com/image/square/de4af7f62b39439905833504e59ba1e153be6d8b/height=288;version=1;width=512/https%3A%2F%2Fginpen.com%2Fwp-content%2Fthemes%2Fginpen-theme%2Fimg%2Ficon-512.png)
const users = [ { id: 101, name: 'Alice', active: true }, { id: 102, name: 'Bob', active: false }, { id: 103, name: 'Charlie', active: true }, ]; const activeUsers = users.filter((v) => v.active); console.log(activeUsers); 仕様 配列のこれ系のメソッドと同じです。 Array.prototype.filter() – JavaScript | MDN newArray = arr.filter(callback(element[, index[, array]])[, thisArg]) 引数 filter() は引数に、関数オブジェクト callback(element
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く