Created
March 6, 2024 17:08
-
-
Save gaizka-allende/52964497188d044edbbf370d0ddaa95b to your computer and use it in GitHub Desktop.
delayed function call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addDelay(msg: string, ms: number) { | |
return () => { | |
setTimeout(() => { | |
console.log(msg); | |
}, ms); | |
}; | |
} | |
const delayedSayHello = addDelay("Hello world!", 500); | |
delayedSayHello(); / |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment