1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

関数を引数に取ったり、関数を戻り値として返す関数のこと。

// 引数に入れるための関数を準備
const double = n => n * 2;

// 関数 fn の引数を num 倍する関数を返す
const hof = (num, fn) => {
  return n => fn(n * num);
}

// 関数 double の引数を2倍する関数(つまり4倍)を返す
const quadruple = hof(2, double);

console.log(quadruple(3)) // 12
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?