eloquent-js-3e-zh icon indicating copy to clipboard operation
eloquent-js-3e-zh copied to clipboard

chapter3

Open bojowa opened this issue 5 years ago • 0 comments

Functions as values A function binding usually simply acts as a name for a specific piece of the program. Such a binding is defined once and never changed. This makes it easy to confuse the function and its name.

But the two are different. A function value can do all the things that other values can do—you can use it in arbitrary expressions, not just call it. It is possible to store a function value in a new binding, pass it as an argument to a function, and so on. Similarly, a binding that holds a function is still just a regular binding and can, if not constant, be assigned a new value, like so:

bojowa avatar Dec 26 '19 12:12 bojowa