Variable declaration:
var v1,v2 = ' Hello ', v3=42;
The data types in JavaScript are divided into two parts: primitive types (numbers, strings, Booleans, Undefined,null), and object types.
-View variable type operator typeof variable or value
-When a number begins with 0, it indicates that it is an octal number. 0377 represents the decimal number 255; The 0x prefix is the hexadecimal number
-Infinity Any number beyond the JavaScript, divided by 0 results is also Infinity
-When strings are used for arithmetic operations, they are used as numeric types. string-and number will be multiplied by 1. or use the parseint () function
Other types-strings are added to the empty string.
-Special word acts when you want to use quotation marks as the contents of a string, \ \ \ \
\u are treated as Unicode codes after the
-Array
var a = [];
When you delete an array element, the array length is not affected, but the position is left blank (undefined).
-check if the variable exists if (typeof somevar! = "undefined")
-Function parameters for passing more parameters, the extra part will only be silently ignored.
-Encoding and de-coding of URIs
encodeURI () result "http://www.packtpub.com/src%20ipt.php?q=this%20" decodeURI
encodeURIComponent () result "http%3a%2f%2fwww.packtpub.com ..." decodeuricomponent
-Variable Scope
A function field always takes precedence over a global domain, and a local variable overrides all global variables that have the same name as it.
When the execution process enters a new function, all variables declared within the function are moved to the beginning of the function.
var a = 123;
function f () {
var a;//same as:var a = undefined
alert (a);//undefined
A = 1;
alert (a);//1
}
The function in JavaScript is also a kind of data, 1. They contain code 2. They are executable (callable)
JavaScript Object-oriented Programming Guide notes