Higher-order functions
Në shqip: Funksionet e rendit të lartë
ShpjegimiSQ
Një funksion i rendit të lartë merr një funksion tjetër si parametër ose kthen një funksion. map, filter, addEventListener dhe setTimeout janë të gjitha të tilla.
EnglishEN
A higher-order function takes another function as a parameter or returns one. map, filter, addEventListener and setTimeout are all examples.
Si ta mendosh
Si një trajner që s'luan vetë, por u thotë lojtarëve si të luajnë.
Lexoje në anglisht
Like a coach who doesn't play but tells the players how to play.
Shembull kodijavascript
const shumezuesi = (x) => (n) => n * x;
const dyfisho = shumezuesi(2);
[1, 2, 3].map(dyfisho); // [2, 4, 6]