May 2011
Intermediate to advanced
1093 pages
40h 54m
English
This section is a tour of the JavaScript language, and also a tour of Part I of this book. After this introductory chapter, we dive into JavaScript at the lowest level: Chapter 2, Lexical Structure, explains things like JavaScript comments, semicolons, and the Unicode character set. Chapter 3, Types, Values, and Variables, starts to get more interesting: it explains JavaScript variables and the values you can assign to those variables. Here’s some sample code to illustrate the highlights of those two chapters:
// Anything following double slashes is an English-language comment.// Read the comments carefully: they explain the JavaScript code.// A variable is a symbolic name for a value.// Variables are declared with the var keyword:varx;// Declare a variable named x.// Values can be assigned to variables with an = signx=0;// Now the variable x has the value 0x// => 0: A variable evaluates to its value.// JavaScript supports several types of valuesx=1;// Numbers.x=0.01;// Just one Number type for integers and reals.x="hello world";// Strings of text in quotation marks.x='JavaScript';// Single quote marks also delimit strings.x=true;// Boolean values.x=false;// The other Boolean value.x=null;// Null is a special value that means "no value".x=undefined;// Undefined is like null.
Two other very important types that JavaScript programs can manipulate are objects and arrays. These are the subject of Chapter 6, Objects, and Chapter 7, ...