How can I learn what the big front-end Web front-end technology skills are essential

How can I learn Web front-end technology? Big front-end skills are necessary? With the update technology as well as business needs change, but to master the basic skills of front-end engineers have been unable to meet demand, companies need is to have more advanced skills, combat experienced great HTML5 front-end engineers. The next one thousand Feng'll tell you about the big front-end skills necessary --JavaScript functional programming.

 

How can I learn what the big front-end Web front-end technology skills are essential

 

 

What is functional programming?

Functional Programming is a programming paradigm, mainly using function to encapsulate the operational procedure, the results calculated by combining various functions. Functional programming means that you can write code with fewer errors in a shorter period of time. Functional programming has two basic characteristics: to convert data of the function, to find a plurality of functions results in series.

JavaScript programming function mode type:

IMPERATIVE: by writing an instruction to let another computer to perform some action, which usually involves a lot of complicated details. Imperative code frequently used statement, to complete an action. Such as for, if, switch, throw and so these statements.

Code Example:

// Imperative

was CEOs = [];

for(var i = 0; i < companies.length; i++){

CEOs.push(companies[i].CEO)

}

Declarative: to declare by writing an expression of the way we want to do, rather than the step by step instructions. Usually complex expression of certain function calls, and operators of some value, the value used to calculate the results.

Code Example:

// declarative

var CEOs = companies.map(c => c.CEO);

Contrast imperative and declarative, we can understand the wording is a declarative expression, without concern for how to counter iteration, how to collect the returned array, which indicates what to do, rather than how to do it. One obvious benefit of this is that functional programming declarative code, no side effects for pure function, we can not consider the internal function is how to achieve, focus on writing business code.

JavaScript functional programming common characteristics:

1, no side effects. Means does not modify the state of the external function is called, i.e. a function call after n still return the same results.

2, transparent reference. It refers to a function only use variables passed to it and create their own internal variables are not used to other variables.

3, immutable variables. Refers to a variable, once created, it can not be modified, any changes will generate a new variable, the biggest advantage of using immutable variables are thread safe. Because JavaScript does not support native immutable variables need to be implemented by third-party libraries (such as Immutable.js, Mori, etc.).

4, functions are first-class citizens. Refers to the function with other data types, on an equal footing, can be assigned to other variables, it can be used as parameters passed to another function, or else as the return value of the function.

Common functional programming model:

1、闭包(Closure)。

If a function references a free variable, the function is a closure. The so-called free variables are not part of the function variables scope. Closure forming conditions: the presence of the local variables, functions and outer layers, the inner layer is a function of the external function is referenced.

The use of closures: the limitations of the scope can define persistence variables can be used for the intermediate buffer or the amount of calculation and the like. Closure of the drawbacks: persistent variables are not normally released, continued take up memory space, is likely to result in wasted memory, so generally requires some additional manual cleanup mechanism.

2, higher-order functions

It refers to a higher order function to function as a function of parameters or function return values, or both to function as a parameter for the function return value again. Functional programming tends to process the data multiplexed with a common set of functional capabilities, it is achieved by using higher-order functions.

JavaScript is a language native support higher-order functions, such as Array.prototype.map, Array.prototype.filter and Array.prototype.reduce JavaScript is built into some of the higher-order functions, the use of higher-order functions make our code more clear and concise .

3, function currying

Currying also known as partial evaluation, currying function will receive some parameters, and then not evaluated immediately, but continue to return a new function, the parameters passed by the form of closure to save, wait until the real evaluation time, and then one-time all incoming parameters evaluated.

Currying is a "pre-load" function approach, with fewer passing parameters to obtain a new function have to remember these parameters, in a sense, this is a parameter of "cache", It is a very efficient way to write functions!

4, function composition (Composition)

A feature of functional programming is to be evaluated by a series function, but with the increase in the number of series function, the readability of the code will continue to decline, function composition is the method used to solve this problem.

Want to learn Web front-end technology, Xiao Bian recommended to choose professional learning system, will let you get started quickly learn a multiplier effect. Web courses and a low threshold for white rapid growth, slow down after learning curve, but also for a certain basis of advanced learning students.

Guess you like

Origin www.cnblogs.com/qianfengzz/p/11612578.html