Closures, higher order functions, overloading

1, the closure

Source defined 1: https: //developer.mozilla.org/zh-CN/docs/Web/JavaScript/Closures
definition itself 1: internal functions can access external scope function, the function can not directly access the external scope internal functions, i.e., internal function is not affected by external interference. This mechanism is called a function closure.

Source definitions 2: "JavaScript Advanced Programming" on page 178
define itself 2: the right to (be able to) access the functions of another variable function scope.

Wherein the closure: function function

Benefits: Closures can function as a return value of the variable is referenced outside, so that the function can access external variables inside a function to reduce the global variables.
Disadvantages: lead scope of a function can not be released, take up memory.


2, higher order function
is defined: function of the other operating functions, such as map, forEach


3, on overloading

Two Java can be defined as a function definition, as long as these two definitions of signatures (the type and number of parameters) can be different. JS is not signed, it can not be overloaded.

Guess you like

Origin www.cnblogs.com/gushixianqiancheng/p/11923601.html