Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Douglas Crockford, in his book JavaScript: the Good Parts calls, functions the “best thing about JavaScript.” He’s right. Once you truly understand them you’ll be certain to agree. The flexibility and power of JavaScript functions can’t be understated.
This is especially true when working with jQuery, a library that fully leverages the expressive power of JavaScript functions.
Basically defined, a function is a block that encapsulates a series of JavaScript statements. Functions can accept and return values. The following code sample shows a simple function statement that explicitly returns the value of a calculation.
function calc( x ){
return x∗2; } console.log( calc( 10 ) )
20
Code snippet is from simple-function.txt