1, the definition of the function of JavaScript species:
@ There are two ways to define a function, one to be anonymous and one to assign to a variable.
@ When you set parameters to a function, you can pass in a number of arguments and then refer to them through arguments within the function, but what is rest ?
2, about the scope of the variable
This means that JavaScript actually has only one global scope. Any variable (the function is also considered a variable), if not found in the current function scope, will continue to look up, and finally, if not found in the global scope, the Referenceerror error is reported.
3. Methods
What is a method in JavaScript? Is there anything you need to be aware of? What is the way of definition? How is the Apply function used?
4. High-order function
The so-called higher order function simply passes a function as a parameter into a function.
f = Math.Abs; function Add (x, Y, f) { return f (x) + f (y);}
5. Map and reduce
function Pow (x) { return x * x;} var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9// [1, 4, 9, +, +, +, +, +, Bayi]
It is more intuitive to write directly with loops.
[X1, x2, X3, x4].reduce (f) = f (f ( f (x1, x2), x3), x4)var arr = [1, 3, 5, 7, 9]; Arr.reduce (function (x, y) { return//
Converts a numeric string to a corresponding integer
function String2int (s) { var arr = S.split (")." Map (function(x) { return x*1 } ); return arr.reduce (function(x, y) { return x*10+y; });}
Learning outlines for JavaScript