ES6 new feature development WeChat applet (6)

Source: Internet
Author: User
Metaprogramming refers to the "programming the language itself" by developers ". Generally, the programming language exposes some APIs for developers to operate on certain features of the language. Starting from ES6, the Proxy and Reflect features have been added, and meta programming has been extended (MetaPro... meta programming refers to developers programming the language itself ". Generally, the programming language exposes some APIs for developers to operate on certain features of the language.

Starting from ES6, the Proxy and Reflect features have been added, and Meta Programming capabilities have been extended to intercept and customize basic language operation behaviors (such as attribute search, assignment, enumeration, function call ).

Proxy)

Proxy is a new feature added to ES6. it can "Proxy" the native behavior of the object and replace it with the execution of custom behavior.

Proxy can be understood as setting up a "blocking" layer before the target object. the external access to this object must first intercept through this layer. Therefore, a mechanism is provided, attackers can filter and rewrite external accesses. The original intention of the word "Proxy" is "Proxy", which indicates that it is used to "Proxy" some operations and can be translated as "Proxy ".

Proxy objects are used to define user-defined behaviors for basic operations (such as property search, assignment, enumeration, and method calls.

Create a Proxy object:

In the above code, each Proxy object's interception operations (get, delete, has) call the corresponding Reflect method internally to ensure that Native behavior can be executed normally. The ADD operation outputs a log line for each operation. With the Reflect object, many operations will be easier to read.

The above is a detailed description of ES6's new feature development applet (6). For more information, see other related articles in the first PHP community!

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.