Javascript for Smart People

Functions

Simple statements are terminated with a semicolon. Compound statements are enclosed in curly braces. A function is a named compound statement. A function can be used any number of times in a program. Functions are named using identifiers, and follow the rules for legal identifiers. A keyword can not be used as a function name.

The Javascript programming language defines built-in functions that can be used to manipulate numbers, strings, and booleans. For example, you want to display a value to the user. You can use the alert() function to do this. It is part of the core Javascript language.

var greeting = 'Landon Sanders';

alert(greeting);

The concatenation operator can be used to combine simple values into one string.

var greeting = 'Hello world!';
var name = 'Landon Sanders';
var age = 39;

alert(greeting + ' My name is ' + name + '. I am ' + age + 'years old.');

"A function is a named compound statement."