Home » JavaScript » First, JavaScript initially knows the -02. variabl...

First, JavaScript initially knows the -02. variables and data types

1. variable

1>. statement: the variables declared var variable; it can also declare variables to assign values to variables; the one can declare a variable or a variable; such as: var a, B, c=1; if only declare a variable without the assignment, the default value is undefined; if the variable name is the variable name will produce coverage; we should strictly distinguish between sensitive, do not contain special characters, should follow the camel notation or underline method, better specific meaning;

Storage and release of

2>. variables in memory:

Collection method: in JS, there is no need to manually release memory, and the release of the garbage storage unit is automatic;

Collecting content;

Recovery algorithm: marking and clearing;

2. data type

1>. raw data type

The numerical type: divided into integer and floating point numbers, but in that is expressed in the double precision floating-point type, a common decimal, hexadecimal or octal number sixteen, there are two special values: Infinity infinity 1.79e309 (also -Infinity infinitesimal) and NaN (NAN Not a Number as the representative. The result of an undefined expression for numeric data, the numerical value is NaN, NaN is the only one not and their comparison value) for example: VAR a=0/0; alert (a); then the NaN; through isNaN () to determine whether the value is NaN; for example: VAR a=0/0; alert (isNaN (a)) will play out; true;

String type: be sure to write between quotes (both single and double). To avoid errors, you can use escape characters;

Boolean type: true, false (to use lowercase);

2>. special data type no defined data types used to indicate no value exists or not assigned to a variable. Variable declaration is not assigned or given a nonexistent attribute value, will make the value of the variable is undefined

Null value null: means nothing, equivalent to a placeholder. The difference between null and undefined is that the undefined indicates that the variable is not assigned, and the null indicates that the variable is given a null value.


3>. composite data type:

Object (object)

Array (array)

Function (function)