Last active
November 6, 2021 03:36
-
-
Save Wockeez/5ca539a624e6d60e75b879985ce2bc9b to your computer and use it in GitHub Desktop.
Самые короткие однострочные вкладыши для ES6+
This file contains hidden or 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
Найдите уникальные id's в массиве. | |
arr.filter((v,i,a)=>a.findIndex(t=>(t.id === v.id))===i) | |
Уникальный по нескольким свойствам ( place и name ) | |
arr.filter((v,i,a)=>a.findIndex(t=>(t.place === v.place && t.name===v.name))===i) | |
Уникальный по всем свойствам (это будет медленно для больших массивов) | |
arr.filter((v,i,a)=>a.findIndex(t=>(JSON.stringify(t) === JSON.stringify(v)))===i) | |
Сохраните последнее событие. | |
arr.slice().reverse().filter((v,i,a)=>a.findIndex(t=>(t.id === v.id))===i).reverse() | |
Фильтр по алфавиту | |
arr.sort((a, b) => a.name > b.name ? 1 : -1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment