20. Immediately Invoked Function Expressions

In This Chapter

Understand anonymous functions

Learn how to invoke a block of code immediately

Take our knowledge of scope further by creating data that is private

We are going to take a slight detour from our coverage of objects to focus on something important that can only properly make sense at this point. You’ll see why in a few moments when we walk through some examples. Anyway, by now, you probably know enough functions in JavaScript to be dangerously productive. Functions allow you to group statements together. If you give your function a name, you can re-use those grouped statements a whole bunch of times, as in the example that follows:

function areYouLucky ...

Get JavaScript Absolute Beginner’s Guide 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.