Javascript functional programming the object nature of JavaScript functional programming:
Function ()
{
Var x = "something ";
Return B (){
// Do with x;
}
}
Var c = ();
Equivalent
Function ()
{
This. x = "dosomething ";
This. B = function (){
// Do with this. x
}
}
Var c = new ();
However
1) functional programming instinctively avoids the construction of useless objects
Function programming encourages you to call closure construction only when closure is used.
Object-oriented objects are usually constructed in advance and ready to be there
2) functional programming protects private variables
X will not be accessed outside the closure.
3) release resources as well as closures and objects.
For example, c = null; setTimeout (CollectGarbage, 100 );
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