What's new in ES2017: Async functions, improved objects and more
ES2017 (ECMAScript 2017) has introduced several important updates to JavaScript, which will focus on and briefly outline its update process.
Core points
- Async functions: Allows you to write asynchronous code based on Promise like you write synchronous code. This feature is supported in all modern browsers (except IE and Opera Mini) and Node.js 7.6.
-
New methods for object processing: include
Object.values()
,Object.entries()
andObject.getOwnPropertyDescriptors()
. These methods are supported in most modern browsers and Node.js 7.0. - String fill methods (.padStart() and .padEnd()): Simplify string formatting. All modern browsers (except IE) and Node.js 8.0 are supported.
- Save trailing commas:Save trailing commas in object definitions, array declarations, function parameter lists, etc. All browsers and Node.js are supported. Trailing commas in function parameters are supported only in Chrome 58 and Firefox 52 at the time of writing.
Update process
JavaScript (ECMAScript) standards are constantly evolving and are implemented by many manufacturers on multiple platforms. ES6 (ECMAScript 2015) took six years to finally be completed and is huge in scale. To simplify the process and quickly add new features, a new annual release process was developed.
Technical Committee 39 (TC39) is composed of participants such as browser manufacturers who follow a strict process to advance JavaScript's proposal:
Stage 0: Strawman – A preliminary idea of new or improved ECMAScript capabilities.
Stage 1: Proposal – A formal proposal document advocated by at least one TC39 member, including API examples, language semantics, algorithms, potential obstacles, polyfills, and demonstrations.
Stage 2: Draft – The initial version of the functional specification. Two experimental implementations are required, one of which can be implemented in a translator such as Babel.
Stage 3: Candidate – Review the proposal specifications and collect feedback from the vendor.
Stage 4: Finished – The proposal is ready to be included in ECMAScript. Only functions that reach this stage are considered standard. However, it may take longer to release in runtimes like browsers and Node.js.
ES2016 is small in scale and is designed to validate standardized processes. Two new features have been added:
- Array's
.includes()
method returns true or false when the array contains a value. -
a ** b
power operator, the same asMath.pow(a, b)
.
New features of ES2017
ES2017 (or formerly known as ES8) is considered to be the first appropriate revision of the ECMAScript specification. It provides the following features...
Async function
Unlike most languages, JavaScript is asynchronous by default. Commands that may take any time will not stop executing. This includes operations such as requesting URLs, reading files, or updating databases. A callback function must be passed that is executed when the result of the operation is known.
This can lead to callback hell when a series of nested asynchronous functions must be executed sequentially. For example:
function doSomething() { doSomething1((response1) => { doSomething2(response1, (response2) => { doSomething3(response2, (response3) => { // etc... }; }); }); }
ES2015 (ES6) introduces Promise, which provides a clearer way to express the same functionality. Once your functions are Promisified, they can be executed using the following methods:
function doSomething() { doSomething1() .then(doSomething2) .then(doSomething3) }
ES2017 Asynchronous function extends Promise to make asynchronous calls clearer:
async function doSomething() { const response1 = await doSomething1(), response2 = await doSomething2(response1), response3 = await doSomething3(response2); }
await
Effectively make each call look synchronous without consuming a single processing thread in JavaScript.
Async functions are supported in all modern browsers (except IE and Opera Mini) and in Node.js 7.6. They will change the way you write JavaScript and can write a special article about callbacks, promises, and asynchronous functions.
The descriptions ofObject.values()
, Object.entries()
, Object.getOwnPropertyDescriptors()
, .padStart()
, .padEnd()
and
SharedArrayBuffer and Atomics
SharedArrayBuffer objects are used to represent fixed-length raw binary data buffers that can be shared among Web Workers. Atomics objects provide a predictable way to read and write memory locations defined by SharedArrayBuffer.
While both Chrome and Firefox implement both objects, it was disabled in January 2018 due to a Spectre vulnerability.
The complete ECMAScript 2017 language specification is available on the ECMA International website.
ES2017 FAQ (FAQ)
(The FAQ part is similar to the original text, and will not be repeated here. You can selectively retain or rewritten as needed.)
The above is the detailed content of What's new in ES2017: Async functions, improved objects and more. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics





Frequently Asked Questions and Solutions for Front-end Thermal Paper Ticket Printing In Front-end Development, Ticket Printing is a common requirement. However, many developers are implementing...

There is no absolute salary for Python and JavaScript developers, depending on skills and industry needs. 1. Python may be paid more in data science and machine learning. 2. JavaScript has great demand in front-end and full-stack development, and its salary is also considerable. 3. Influencing factors include experience, geographical location, company size and specific skills.

JavaScript is the cornerstone of modern web development, and its main functions include event-driven programming, dynamic content generation and asynchronous programming. 1) Event-driven programming allows web pages to change dynamically according to user operations. 2) Dynamic content generation allows page content to be adjusted according to conditions. 3) Asynchronous programming ensures that the user interface is not blocked. JavaScript is widely used in web interaction, single-page application and server-side development, greatly improving the flexibility of user experience and cross-platform development.

How to merge array elements with the same ID into one object in JavaScript? When processing data, we often encounter the need to have the same ID...

Discussion on the realization of parallax scrolling and element animation effects in this article will explore how to achieve similar to Shiseido official website (https://www.shiseido.co.jp/sb/wonderland/)...

Learning JavaScript is not difficult, but it is challenging. 1) Understand basic concepts such as variables, data types, functions, etc. 2) Master asynchronous programming and implement it through event loops. 3) Use DOM operations and Promise to handle asynchronous requests. 4) Avoid common mistakes and use debugging techniques. 5) Optimize performance and follow best practices.

In-depth discussion of the root causes of the difference in console.log output. This article will analyze the differences in the output results of console.log function in a piece of code and explain the reasons behind it. �...

Explore the implementation of panel drag and drop adjustment function similar to VSCode in the front-end. In front-end development, how to implement VSCode similar to VSCode...
