Chapter 11. Serious functions
Anonymous Functions, Scope and Closures
Youâve put functions through their paces, but thereâs more to learn. In this chapter we take it further; we get hard-core. Weâre going to show you how to really handle functions. This wonât be a super long chapter, but it will be intense, and at the end youâre going to be more expressive with your JavaScript than you thought possible. Youâre also going to be ready to take on a coworkerâs code, or jump into an open source JavaScript library, because weâre going to cover some common coding idioms and conventions around functions. And if youâve never heard of an anonymous function or a closure, boy are you in the right place.
Note
And if you have heard of a closure, but donât quite know what it is, youâre even more in the right place!
Taking a look at the other side of functions...
Youâve already seen two sides of functionsâyouâve seen the formal, declarative side of function declarations, and youâve seen the looser, more expressive side of function expressions. Well, now itâs time to introduce you to another interesting side of functions: the anonymous side.
By anonymous weâre referring to functions that donât have names. How can that happen? Well, when you define a function with a function ...
Get Head First JavaScript Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.