JS Coding Questions Logo
JS Coding Questions
#354💼 Interview💻 Code

What is a thunk function

Advertisement

728x90

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
1const add = (x, y) => x + y;
2
3const thunk = () => add(2, 3);
4
5thunk(); // 5

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 11

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
354of476