It's hard to finish the code on this book, and now I'll start with a brief look at it.
The first two chapters briefly introduce the syntax of JavaScript, because this book is mainly about DOM, so it's relatively simple here, basically around the area.
Chapter One A brief history of JavaScript. Just understand, whatever it is.
Chapter II JavaScript syntax.
1. The statement (statement) should be followed by a semicolon, which is a good programming habit to develop.
2. Note (comment) Single-line comment//, multiline comment/* */.
3. Variable (variable), Assignment (Assignment), declaration (declare), literal (literal)
JavaScript can be assigned without declaring a variable, but it is not a good habit to declare multiple variables in a single statement.
The variable names in JavaScript are case-sensitive, allow letters, numbers, $, and underscores (but the first character cannot be a number), and do not allow spaces and punctuation marks (except $).
4.JavaScript is a weakly typed (weakly typed) language, meaning that you can change the data type of a variable at any time.
String (string), numeric value (number), Boolean (Boolean) are scalar (scalar) in this book is just a brief introduction.
5. An array array is a set of values represented by a variable, and each value in the collection is an element of the array.
The number of array elements is the length of the array, and the element to be added to the array is called padding (populating).
Declaration method: var beatles = Array (number); var beatles=[];var beatles = new Array ();
padding: array[index]=element; array elements can be of various data types and can even be mixed and even contain other arrays
Associative Arrays : You can use strings instead of numeric values. Essentially, when you create an associative array, you create an array object's properties. The authors do not recommend this approach. (although he used it later)
1 var lennon = Array (); 2 lennon["name"] = "John"; 3 lennon["Year"] = 1940; 4 false;
6. Objects (object) are self-contained data sets that can be accessed in two ways by the data contained in the object (property), method
A property is a variable that belongs to a particular object, and is a function that only a particular object can call. In JavaScript, properties and methods are accessed using the "dot" syntax.
Object.property;object.method ();
This book is just a brief introduction to the object, and not in-depth understanding.
7. Variable scope (scope), variables can be either global or local.
Global variable can be referenced anywhere in the script. A local variable (locally variable) exists only inside the function that declares it, and cannot be referenced externally.
"JavaScript DOM Programming Art" (second edition) reading notes (i)