JavaScript closure-Is there a difference between a closure function and an anonymous function in PHP, what is a closure?

Source: Internet
Author: User
What the hell is a closure? Before JS inside heard some, but the actual development how do not feel how to use this concept? Just recently when learning laraval, found that the routing configuration is the closure function (the tutorial said that), do not understand what this closure means? I see the code and JS inside the anonymous function is very similar AH? Thank you for answering ﹏.

Reply content:

What the hell is a closure? Before JS inside heard some, but the actual development how do not feel how to use this concept? Just recently when learning laraval, found that the routing configuration is the closure function (the tutorial said that), do not understand what this closure means? I see the code and JS inside the anonymous function is very similar AH? Thank you for answering ﹏.

Closures are a free block of code, in most language closures, basically in the form of anonymous functions, in PHP and JS can be interpreted as a closure of anonymous functions, the two are consistent. Of course, in PHP, there are also closure objects to operate closures.

  • 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.