September 2015
Intermediate to advanced
92 pages
1h 30m
English
CHAPTER 8
![]()
Functions
Functions are reusable code blocks that will only execute when called. They allow developers to divide their scripts into smaller parts that are easier to understand and reuse.
Defining Functions
To create a function the function keyword is used followed by a name, a set of parentheses, and a code block. The naming convention for functions is the same as for variables – to use a descriptive name with each word initially capitalized, except for the first one.
function myFunc(){ document.write("Hello World");}
This function simply displays a text string to the web document. A function code block can contain any JavaScript code, ...
Read now
Unlock full access