O'Reilly logo

The JavaScript PocketGuide by Lenny Burdette

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

5. Functions

Functions are remarkably flexible in JavaScript. That flexibility provides a lot of power, but it can also create confusion, especially in how functions interact with variables and objects. This chapter covers some pretty advanced concepts; some nuances might not stick with you right away, but once you spend some time with functions, you’ll really start to appreciate the power of the JavaScript language.

Creating Functions

The two ways to create functions both use the function keyword, so the differences between them aren’t immediately apparent.

Declarations

Variable declarations and function declarations operate similarly. They start with a keyword (var or function), followed by an identifier. Function declarations add lists ...

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