1. Variables
Define variables using the var keyword,
function Test () { var 'one'; } Test (); alert (cc); // error not defined variable If you remove Var, it will pop up 11 ... This example can explain the use of global variables and local variables.
2. Data type: Undefined,null,boolean,number, and string. There are also 1 of complex object,js that do not support any mechanism for creating custom types
Undefind and null are data types with only one value, and from a logical point of view, a null value represents an empty object pointer, which is why using the TypeOf operator to detect that a null value returns an object, if a variable is defined to be stored in the future. It is a good idea to initialize the variable to null instead of the other value, so that if you check the value of NULL, you know whether the corresponding variable has saved a reference to an object: for example:
var car=null; if (Car! =null) {// This side can do some work on the car's objects }
In fact, undefined refers to the derivation of a null value, so ECMA-262 specifies that the test of equality to them returns true;
Alert (Null = = undefined)//result returns true;
The Boolean type is the most used type in ECMAScript, which has only true and false, which is not the same as a numeric value, so true is not necessarily equal to 1, and false is not necessarily equal to 0, and true and false are identifiers, Not a Boolean value, case sensitive
All types of values can be converted to a Boolean value, call the Transform function Boolean (), as to whether the return is true or false, depending on the data type of the converted value and the actual value
Convert the value of the data type to True to a value of false Booleantrue falsestring any non-empty string "" (empty string) number any non-0 value 0 and Nanobject any object nullUndefined n /a undefined
`
Learn some of the memory things of JavaScript