Learn JavaScript - Higher Order Functions and Iterators - Learn JavaScript - Iterators Cheatsheet - Codecademy
Learn JavaScript - Higher Order Functions and Iterators - Learn JavaScript - Iterators Cheatsheet - Codecademy
plusFive(3); // 8
// Since f has a function value, it can
be invoked.
f(9); // 14
Callback Functions
In JavaScript, a callback function is a function that is const isEven = (n) => {
passed into another function as an argument. This
return n % 2 == 0;
function can then be invoked during the execution of
that higher order function (that it is an argument of). }
Since, in JavaScript, functions are objects, functions
can be passed as arguments.
let printMsg = (evenFunc, num) => {
const isNumEven = evenFunc(num);
console.log(`The number ${num} is an
even number: ${isNumEven}.`)
}
https://www.codecademy.com/learn/game-dev-learn-javascript-higher-order-functions-and-iterators/modules/game-dev-learn-ja… 1/4
18/10/2023, 11:20 Learn JavaScript: Higher Order Functions and Iterators: Learn JavaScript: Iterators Cheatsheet | Codecademy
Higher-Order Functions
In Javascript, functions can be assigned to variables in
the same way that strings or arrays can. They can be
passed into other functions as parameters or returned
from them as well.
A “higher-order function” is a function that accepts
functions as parameters and/or returns a function.
https://www.codecademy.com/learn/game-dev-learn-javascript-higher-order-functions-and-iterators/modules/game-dev-learn-ja… 2/4
18/10/2023, 11:20 Learn JavaScript: Higher Order Functions and Iterators: Learn JavaScript: Iterators Cheatsheet | Codecademy
console.log(sum); // 10
console.log(announcements);
https://www.codecademy.com/learn/game-dev-learn-javascript-higher-order-functions-and-iterators/modules/game-dev-learn-ja… 3/4