aderaaij
3/8/2018 - 4:05 PM

arrow functions in functions

Arrow functions returning functions seem kinda magical, but if you write it out, it's not that hard to see what's going on!

const func = data => id => data.find(item => item.id === id);
function func(data) {
    return function(id) {
        return data.find(function(item) {
            return item.id === id;
        })
    };
};