O'Reilly logo

Beginning Facebook Game Apps Development by Wayne Graham

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

Functions

Functions are pieces of code within your program that perform a specific task. By using functions, you are able to write reusable code, not only within the context of the program you are writing, but also with other programs that you may write. In JavaScript, a function consists of the keyword function, followed by the name of the function, a list of arguments, and the JavaScript statements.

The contents of a function (the function body) include some coding logic, and even calls to other functions. This is a way in which you can share bits of code throughout your program. However, on its own, a function is never executed. It needs to be called in the execution of your code. This is done by calling the function by its name. Take the ...

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