The 1:typeof is used to determine the data type of the variable, although NULL is the null data type, but the object data type is returned, although the function is the object data type, but it returns the function type
var x=null;typeof x;
"Object"
function X () {}; typeof X;
"Function"
The 2:undefined value is derived from a null value, and the equality test for them returns true; = = "operator converts its operand in the comparison purpose
Undefined==null
True
The literal value of the 3:boolean type True and false is case-sensitive, that is: true and False are not Boolean values, are identifiers
var y=true;y;
True
4: The Boolean function can be called on a value of any data type and always returns a Boolean value; If statement automatically performs the corresponding Boolean conversion
Boolean (0)
False
Boolean ("")
False
Boolean (undefined)
False
Boolean (NULL)
False
Boolean (False)
False
Boolean (NaN)
False
5:ECMASCRIPT5 introduces the concept of strict mode: a browser that supports strict mode includes ie10+,firefox4+,safari5.1+,opera12+ and chrome by adding code to compile the top of the script to indicate "use strict"
"Use Strict"
function X () {x=5;}
X ();
Undefined
6: Octal and Hex
var x=070,y=9;x+y
65
var x=0xa,y=9;x+y
19
var x=0xa,y=9;x+y
19
7: Floating point calculation is a common problem based on IEEE754 value, and floating-point numerical calculation produces rounding error
0.1+0.2
0.30000000000000004
8:nan Two features: any operation involving Nan returns Nan;nan and any value is unequal, including itself
5/0
Infinity
nan/0
NaN
Nan==nan
False
9:
Number ("")
0
parseint ("")
NaN
Number (NULL)
0
parseint (NULL)
NaN
Number (undefined)
NaN
parseint (undefined)
NaN
Number (456KK)
Vm1205:2 uncaught syntaxerror:unexpected Token illegal
Number ("456KK")
NaN
parseint ("456KK")
55W
parseint (False)
NaN
parseint (22.5)
22
parseint (070,8)
46
parseint (0xa)
10
Parsefloat (0xa)
10
Parsefloat (0xa,10)
10
Parsefloat (0xa,16)
10
10: Chinese two bytes, the return value has a problem
var x= "Hello"; x.length
2
11: Convert string: ToString () method, String () function, + empty string
var x=1;x.tostring ()
"1"
var x=20;x.tostring (16)
"14"
var x=null; String (x)
"NULL"
var x=undefined; String (x)
"Undefined"
Undefined+ ""
"Undefined"
1+ ""
"1"
Null+ ""
"NULL"
True+ ""
"True"
The difference between the 12:ecmascript operators is that they can be applied to many values, such as: strings, numeric values, Booleans, and even objects
var x= ""; x + +
0
var x=true;x++
1
True+false
1
True+ ""
"True"
True+ "CCC"
"TRUECCC"
true+{}
"True[object Object]"
{}++
Vm2136:3 uncaught syntaxerror:unexpected Token}
var x={};x++
NaN
({}) +true
"[Object Object]true]
13: Bitwise operator (unsigned right shift >>>, signed right shift >>, left shift <<, bitwise XOR, bitwise OR |, bitwise and &, bitwise NOT ~)
var x=100;
X=~x
-101
var x=25&3
Undefined
var x=25 & 3
Undefined
var x=25 & 3;x
1
var x=25 | 3
Undefined
var x=25 | 3;x
27
var x=25 ^ 3;x
26
14:boolean type conversion method:!! Method and the Boolean method
var x= ""; Boolean (x);
False
var x= "";!! X
False
15: Logic and
({}) && true
True
True && ({})
Object {}
"" && True
""
Null && True
Null
False && ({})
False
"" && null
""
Basic JavaScript Concepts