ES6 new features development WeChat applet (2)

迷茫
Release: 2017-03-25 17:24:34
Original
2311 people have browsed it

Template Literals (template object)

The template string (Template String) in ES6 is a string that can embed expressions in the string text. String Literal.

They look the same as ordinary strings, except that the backtick character ` is used instead of the quotation marks ' or " of ordinary strings.

ES6 new features development WeChat applet (2)

##Different from ordinary strings, template strings can be written in multiple lines.

ES6 new features development WeChat applet (2)

#All spaces, new lines, and indents in the template string will be output as is in the generated string ##.

#Extended Literals

ES6 adds two new numeric identifiers, the second letter is b Represents binary, the second letter is o to represent octal

ES6 new features development WeChat applet (2)
ES6 better supports Unicode. Supports Unicode for extended strings and
regular expressions

##Enhanced Regular Expression

ES6 adds the u modifier to the regular expression, which means "Unicode mode" to correctly handle Unicode characters larger than \uFFFF. In other words, four-byte UTF-16 encoding will be correctly processed.

##In the above code, \uD83D\uDC2A is a four-byte UTF-16 encoding, which represents a character. "u" will be recognized as 2 characters according to ES5. After adding "u", it will be correctly recognized as one character according to ES6

ES6 new features development WeChat applet (2)ES6 regular expression. The y modifier is added, called the "sticky" modifier. The y modifier is similar to the g modifier, and it is also a global match. The difference is that the next match starts from the position where the previous match was successful. , the g modifier only requires a match in the remaining positions, and the y modifier ensures that the match must start from the first remaining position

#.

ES6 adds a sticky attribute to regular expressions, which is used to indicate whether the regular object has the y modifier set.

ES6 new features development WeChat applet (2)

##ES6 adds a new flags attribute to regular expressions, returning the modifiers of regular expressions

ES6 new features development WeChat applet (2)
##

Enhanced Object Literals(Enhanced Object Literals)

The concise representation of new properties in ES6 allows direct writing of variables and functions as properties and properties of objects. method. This kind of writing is more concise.

ES6 new features development WeChat applet (2)

In addition to property abbreviations, ES6 methods can also be abbreviated.

ES6 new features development WeChat applet (2)

ES6 adds new attribute name expressions, allowing expressions to be used as objects when literals are defined. attribute name, that is, put the expression within square brackets.

ES6 new features development WeChat applet (2)

ES6 new features development WeChat applet (2)##Destructuring Assignment

ES6 allows Extracting values ​​from arrays and objects and assigning values ​​to variables according to a certain pattern is called destructuring.

Destructuring assignment allows you to assign properties of arrays and objects to various variables using syntax similar to array or object literals. This assignment syntax is extremely concise and clearer than traditional property access methods.

Destructuring assignment of arrays can extract values ​​from the array and assign values ​​to variables according to the corresponding positions.

ES6 new features development WeChat applet (2)

Destructuring assignment of objects.

ES6 new features development WeChat applet (2)

Destructuring assignment of string, the string is converted into an array-like object.

ES6 new features development WeChat applet (2)

Destructuring assignment of function parameters

ES6 new features development WeChat applet (2)
##

The above is the detailed content of ES6 new features development WeChat applet (2). For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template