Chapter III Basic Concepts
1. In JavaScript is case-sensitive, the first character is the letter _ or $, the other characters can try the number of letters _ or $, the naming format requirements are camel writing (the first letter lowercase, the remainder of each meaningful word beginning capital such as FontSize)
2. Single-line comment//block-level comment */* Multiline content * * Do not use keywords and reserved words
3. In JavaScript, variables are loosely typed and can be of any type
4. A variable defined with the var operator becomes a local variable in the scope that defines the variable.
function Test () {
var i = ' Hi ';
}
Test ();
alert (i);//error, I is local variable
5. Data type: Undefined Null number String Boolean (base data type) Object
The 6.typeof operator can detect the data type of a given variable
Undefined detection value not defined
Boolean detection value is a bool value
String detection value
Number detection value is numeric
The object detection value is a reference to a Null///null object or a null
function detection values are functions
7. If a value is declared but not initialized, this value is for undefined
8.null represents a pointer to an empty object, undefined derived from null
When alert (null=undefined);//true
When alert (nul===undefined);//false
The 9.Boolean type has only true and false.
For false 0 NaN null and undefined to false the rest is true
10.Number (), parseint (), parsefloat () can be converted numerically
Number () can be used for any data type if the value is undefined returns Nan, and the leading 0 empty string is ignored and null is 0 parseint () and parsefloat () as its name
11. To convert any data to a string, you can call the ToString (value) method, which returns a string form, where value is an optional parameter that can be passed into the binary
such as var num = 10; Num.tostring (2);//1010 defaults to No parameters (10 binary)
You can call string () to convert a string (value) when you do not know whether the value is undefined or null, and value to return the original data directly when it is undefined and null
12.Object type: A set of data and functions that objects are created after the new operator is executed
You can create a custom pair of objects var i = new Object (); Note O is uppercase
JavaScript Advanced Programming Third Edition reading notes