What is a "thunk"?

Thunk is a function that wraps another function or expression to delay computation. Thunk can also be used to add additional calculations to a function.
Thunks provide lazy evaluation and are widely used in functional programming languages.

If you are looking for Redux Thunk, check out this answer: What is Redux Thunk?.

Example

Here’s an example of using a thunk myFunction to delay evaluation of an expression in JavaScript:

// calculation of 1 + 2 is immediate
let x = 1 + 2;
 
// calculation of 1 + 2 is delayed
// myFunction can be called later to perform the calculation
let myFunction = () => 1 + 2;

Applications

  • Functional programming and lazy evaluation
  • Inheritance of multiple interfaces in object-oriented programming
  • Interoperability between software modules
New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved