Skip to content

Instantly share code, notes, and snippets.

@Nothing-Works
Created November 29, 2019 04:52
Show Gist options
  • Select an option

  • Save Nothing-Works/e11dea75a4e78781a21919d6a6f88b00 to your computer and use it in GitHub Desktop.

Select an option

Save Nothing-Works/e11dea75a4e78781a21919d6a6f88b00 to your computer and use it in GitHub Desktop.
random ST question
let arr = [
{
name: 'user',
age: 1
},
{
name: 'teacher',
age: 9
},
{
name: 'user',
age: 2
},
{
name: 'teacher',
age: 8
},
{
name: 'accountant',
age: 3
},
]
let result = [...new Set(arr.map(a => a.name))].map( key => [...arr.filter(c=>c.name === key)]);
console.log(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment