Chapter 9. JavaScript: Functions

 

Form ever follows function.

 
 --Louis Sullivan
 

E pluribus unum. (One composed of many.)

 
 --Virgil
 

O! call back yesterday, bid time return.

 
 --William Shakespeare
 

Call me Ishmael.

 
 --Herman Melville
 

When you call me that, smile.

 
 --Owen Wister

OBJECTIVES

In this chapter you will learn:

  • To construct programs modularly from small pieces called functions.

  • To create new functions.

  • How to pass information between functions.

  • Simulation techniques that use random number generation.

  • How the visibility of identifiers is limited to specific regions of programs.

Outline

9.1

Introduction

9.2

Program Modules in JavaScript

9.3

Programmer-Defined Functions

9.4

Function Definitions

9.5

Random Number Generation

9.6

Example: Game of Chance

9.7

Another ...

Get Internet & World Wide Web: How to Program, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.