Linux Today: Linux News On Internet Time.

Functional JavaScript: Harnessing the power of the Function Object

Jan 26, 2009, 22:02 (3 Talkback[s])
(Other stories by Rob Gravelle)

"Functional Programming: What It's All About
Functional Programming emphasizes the evaluation of expressions rather than the execution of commands. Tracing back to calculus mathematics, the main goal of Functional Programming is to prevent the inadvertent changing of already calculated values. As developers know, the most likely cause of accidental variable modifications are functions that have access to global objects. The reason accessing of global variables by multiple functions is inherently dangerous is that changing a global variable in part of a program can have unexpected effects in another part. Functional programming isn't a replacement for Object-Oriented and Pricedural/Imperative styles; each has a place in Web development. Examples of Functional Programming languages include Scheme, Erlang and Haskell.

"Higher Order Functions
A function becomes a Higher Order function when it treats other functions as values. JavaScript is well suited for this type of programming because functions are actually a Function object type. Observe the following two functions:"

Complete Story

Related Stories: