Basic knowledge
1. Comment/**/block comment, conflict with regular expression, unsafe.
2.js numeric type has only one, which is a 64-bit floating value
3.NaN is a numeric value, and he cannot produce the result of a normal result. Nan is not equal to any value, including its own. isNaN detect if Nan
All characters in 4.Js are 16 bits.
5. Declaration of functions and definition of functions:
function declaration
Console.log (f);
function f (x) {
return x;
}
function definition
Console.log (z);//undefined
var z = function (x) {
return x;
};
The difference: The function definition, just the variable declaration ahead of time, the initialization code of the variable is still in its original position. function declaration: Both the function name and the function body are in advance, and all functions and functions nested within the script are declared before the other code. (variable promotion, z is what variable will be promoted, here just to illustrate the difference between function declaration and definition)
Array
var a = [1,,,, 5];//other three values are undefined sparse array
var b = [1,2,3,4];
var c = [5,6];
1.concat ()
B.concat (c);//[1,2,3,4,5,6]
2.join
C.join ();//5,6
C.join ("");//56
C.join ("-");//5-6
3.reverse (); reverse
4.splice ()//delete and insert
1) Delete
B.splice;//1 for deleting several from the beginning of the first 2
2) Insert
B.splice (1,2,33,44,44,22);//1 is a number from the beginning of the first, 2 for the deletion of a few, 2 after the numeric value is inserted.
5. Some of the loops, the same parameters, the function is different. The return value is also not possible.
1) Every return value: Boolean
B.every (function (v, I, arr) {
V Self-value, I-index, arr array
});
2) foreach, map, some, filter
6.slice () Select Slice (start,end)//Include start excluding end
Event:
AddEventListener (A, B, c)//a functions called for event names such as Click,b, C is the capture handler
This method registers multiple handler functions of the same event type for an object
varBTN = document.getElementById ('btn'); Btn.addeventlistener ('Click', function () {alert ('a'); ); Btn.addeventlistener ('Click', function () {alert ('b');} ); Btn.onclick=function () {alert ('cc');};
Btn.onclick=function () {alert ('DD');};
Alert ("CC") is not executed here;
Some special knowledge of JavaScript