O'Reilly logo

JavaScript Absolute Beginner’s Guide by Kirupa Chinnathambi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required