Conceptual Question

What is a thunk?

JavaScript

What is a thunk?

JavaScript

Thunk

A thunk is a function that has everything already that it needs to do to give you some value back. You do not need to pass any arguments in, you simply call it and it will give you a value back.

JAVASCRIPT
1function add(x, y) {
2 return x + y;
3}
4
5var thunk = function () {
6 return add(10, 15); // 25
7};
8
9thunk();

Continue with nearby questions from the same topic cluster.