Odd Dance JS Note--*--process abstraction, higher order function, function oriented programming

Source: Internet
Author: User

Note:

1. Learn the video address

2.ppt Address

3. Personal Impressions:

Is my great master recommended me to see the shadow of the month big video, I feel for this small white, really is over and over again refresh knowledge. I feel like the Moon shadow greatly this big guy's train of thought, my contact after really benefited.

So I summed up not only my own notes, but also want to be a true front-end "engineer" front-end er.

Really cherish this knowledge is refreshed feeling-the more study, the more feel their ignorance, mutual encouragement.

Summary

1. The data abstraction is for the processing;

2. process abstraction (e.g. higher-order functions) is for function processing;

3. use higher-order functions to modify the interface of an existing API without affecting the internal content of the function.

Directory

One problem: Modifying the order of parameters in an existing API

1. Direct rewrite

2. New function call

3. Using higher-order functions

4. Summary

Body

problem: To change the order of parameters in an API:

1. Direct Rewrite
function SetColor2 (el,color) {    El.style.color=color;}

Disadvantages:

if the API is complex, rewriting costs are high

And it's a bad name.

2. new function Call

function SetColor2 (el,color) {    setcolor (color,el);}

No need to control API internal logic, but still not good naming and management

3. create higher-order functions

Can reverse the order of all functions

function Reverseargs (FN) {    returnfunction(... args) {        args=args.reverse ()        ; return fn.apply (this, args)    }}setcolor=reverseargs (setcolor);

Do not modify other people's code, do not care about the specific function, only the abstract process

Very High reusability

scalability is high, for example :

use timeout to make the function Execute after a few milliseconds, with bind after the function Milliseconds to execute output statements

(Changed the API's more interface information)

Summary:

1. The data abstraction is for the processing;

2. process abstraction (e.g. higher-order functions) is for function processing;

3. use higher-order functions to modify the interface of an existing API without affecting the internal content of the function.

Odd Dance JS Note--*--process abstraction, higher order function, function oriented programming

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.