Subsets and hyper-sets of javascript

Source: Internet
Author: User

1. JavaScript subset

The definition of a subset of JavaScript is mostly for security reasons, and only a secure subset of the language is used to write scripts that enable the code to run more securely and stably. For example, how to run a more secure ad code that is provided by untrusted third parties. A subset of JavaScript generally removes some of the features of JavaScript. such as Adsafe, Dojox.secure, Caja, FBJS, and Microsoft's Web sandbox, all of these implement a security subset.

2. Constants and Local variables

Constants are represented by Const. A local variable is represented by let, which declares a block-level scope. The out-of-scope variable is invalid.

3. Deconstruction Assignment

The deconstruction assignment is a hybrid assignment, a concept in Python that looks directly at the following examples:

let [x, y] = [12let12;
4. iterators

Iterators use methods similar to Python, iterators must include the next () method, and for an iterative object, a method called d__iterator__ () must be defined.

5. Generator

Generator, using the same method as the Python,yield keyword for production, there are two methods, next () and send ().

6. Array derivation

The array derivation, using the same method as Python, has the following format:

expressionforinif (condition) ]

Like what:

letforin range(010if20)]

Evensquares is an array that represents the square of even numbers between 0~10.

7. Generator expression

The generator expression. The use method is similar to Python, and the square brackets in the array derivation are replaced with parentheses. Returns an object rather than an array.

8, function shorthand

function shorthand is useful for simple functions, i.e., expression closures. Omit the return keyword and braces, such as the following example:

letfunction(x) x+1;
9. Exception handling for multiple catch statements

In exception handling. Can have multiple catch statements, and the capture condition can be inferred using if. To capture what we need.

10, e4x

E4X, or ECMAScript for XML, is a standard extension of JavaScript that defines a series of powerful features for working with XML documents.

Subsets and hyper-sets of javascript

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.