Object.groupBy
Në shqip përdoret i njëjti emër.
ShpjegimiSQ
Object.groupBy(vargu, fn) i grupon elementet sipas vlerës që kthen funksioni — p.sh. nxënësit sipas klasës — pa e shkruar vetë me reduce.
EnglishEN
Object.groupBy(array, fn) groups items by the value the function returns — e.g. students by class — without writing it yourself with reduce.
Si ta mendosh
Si t'i ndash rrobat në pirgje sipas ngjyrës.
Lexoje në anglisht
Like sorting laundry into piles by colour.
Shembull kodijavascript
const grupet = Object.groupBy(nxenesit, n => n.nota >= 5 ? "kalues" : "mbetes");