I use this pattern quite often in JavaScript. Here is an example:
const comments = [
{ text: 'Hello', id: 1 },
{ text: 'World', id: 4 },
];
const byId = id => element => element.id === id;
const comment = comments.find(byId(1));
Sometimes, this pattern can make our code readable and modular. What is this pattern called?
Best Answer
They are called higher-order functions.