JavaScript-Functional programming

Source: Internet
Author: User

Object nature of functional programming for javascript:  
Function a ()  

    var x= " Sth ";   
     return b () { 
         //do with x; 
     } 

var  c = a ();  
equivalent to  
Function a ()  

         this.x =  "Dosth";  
         This.b = function () { 
               //do with this.x 
        } 

Var c = new a ();  

But  
1) functional programming instinctively avoids the construction of useless objects  
Because functional programming encourages closure construction when used with closures, object-oriented objects are usually constructed in advance and ready to be there.
2) Functional programming to protect the private variable  
x will not be accessed externally outside of the packet  
3) Closures and objects should be aware of releasing resources  

such as: c = null; SetTimeout (collectgarbage,100);

JavaScript-Functional programming

Related Article

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.