2020-02-26から1日間の記事一覧
高階関数 // 引数に関数をとる arr = [1, 2, 3] arr.map(n => n * 2); // 戻り値として関数を返す const hof = (ex, fn) => { retrun n => fn(n + ex); }; const plusOneDouble = hof(1, n => n * 2); console.log(plusOneDouble(4)); // (4 + 1) * 2 = 10 /…
高階関数 // 引数に関数をとる arr = [1, 2, 3] arr.map(n => n * 2); // 戻り値として関数を返す const hof = (ex, fn) => { retrun n => fn(n + ex); }; const plusOneDouble = hof(1, n => n * 2); console.log(plusOneDouble(4)); // (4 + 1) * 2 = 10 /…