Java Reference
In-Depth Information
Chapter
11
Functional JavaScript
Functional programming uses functions as the building blocks of a program and avoids
changing the state of data. This means that a program becomes a sequence of expressions
based on the return values of functions. The return value of a function should only depend
on the values provided as arguments.
Functional programming has gained momentum in recent years with a dedicated following.
The popularity of purely functional languages such as Clojure, Scala, and Erlang sparked
an interest in functional programming techniques that continues to grow. JavaScript has al-
ways supported functional-style programming due to functions being first-class objects. This
facilitates some of JavaScript's most interesting techniques—such as callbacks and clos-
ures—that can be used to create cleaner code that is flexible and powerful.
In this chapter, we'll cover the following topics:
• introduction to functional programming
• function properties and methods
• functions that return functions
• callbacks
• closures
• immediately Invoked function expressions
• self-defining functions
• recursive functions
• currying
• our project―improve some of the functions using techniques from this chapter
Search WWH ::




Custom Search