Chapter 4Functions
In the last chapter, we covered arrays, logic, and loops. In this chapter, we’re going to look at functions. A function is a chunk of code that is almost like a small, self-contained mini program that can be referenced by a name. They can help to reduce repetition and make code easier to follow.
In this chapter, we’ll be covering these topics:
-
defining functions―function declarations, function expressions, and
Function()constructors -
invoking a function
-
return values
-
parameters and arguments
-
scope―global and local
-
hoisting―variables and functions
-
callbacks―functions as a parameter
-
project―we’ll be using functions to make it simpler to understand the Quiz Ninja code
In JavaScript, functions are considered to be just ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access