Higher-order function: Difference between revisions

Content deleted Content added
m C++: linking
m JavaScript: Added a more legible equivalent to the arrow-function syntax, for non-Js users.
Line 422:
{{further information|JavaScript}}
 
With arrow functions:
<syntaxhighlight lang="javascript">
"use strict";
Line 431 ⟶ 432:
const g = twice(plusThree);
 
console.log(g(7)); // 13
</syntaxhighlight>
 
Or with classical syntax:
<syntaxhighlight lang="javascript">
"use strict";
 
function twice(f) {
return function (x) {
return f(f(x));
};
};
 
function plusThree(i) {
return i + 3;
}
 
const g = twice(plusThree);
console.log(g(7)); // 13
</syntaxhighlight>