January 2019
Beginner
210 pages
4h 47m
English
A higher-order function is a function that does at least one of the following:
Higher-order functions are some of the most powerful tools that we can use to write JavaScript in a functional programming style. Let's look at some examples.
The following code snippet declares a function named addDelay. The function creates a new function that waits for a given number of milliseconds before printing a message in the console. The function is considered a higher-order function because it returns a function:
function addDelay(msg: string, ms: number) { return () => { setTimeout(() => { console.log(msg); }, ms); };}const delayedSayHello = addDelay("Hello ...Read now
Unlock full access