InterviewHubPRO
Section Overview
Q358

Question 358 of 521

Part 6: Async Internals, Memory, Microtasks & Web APIs (329 - 403)

69%
JavaScript Internals (521 Qs)•Part 6: Async Internals, Memory, Microtasks & Web APIs (329 - 403)

What is a thunk function

A thunk is just a function which delays the evaluation of the value. It doesn’t take any arguments but gives the value whenever you invoke the thunk. i.e, It is used not to execute now but it will be sometime in the future. Let's take a synchronous example,

javascript
  const add = (x, y) => x + y;

  const thunk = () => add(2, 3);

  thunk(); // 5