Chapter 5. Functions


JavaScript functions are a key part of the language, but they're not quite what they seem. They look like they would belong in the family of statements, but in actuality, they're objects just like all the others we've covered in the last chapter. You can define a function, create a new one, even print one out.

Thanks to this functionality, you can assign a function to a variable, an array element, or even pass one as an argument to another function call. This makes using functions a very handy and flexible beastie, but also a confusing one.

It's easy to get lost in discussions of anonymous functions as compared to function statements, function expressions, and references to literal functions. Add in concerns about function closure and memory leaks, as well as properties inherited by all functions, and you can see they are not a trivial JavaScript construct.




Learning JavaScript
Learning JavaScript, 2nd Edition
ISBN: 0596521871
EAN: 2147483647
Year: 2006
Pages: 151

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net