BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News V8 4.9 Released with 91% ECMAScript 2015 Support

V8 4.9 Released with 91% ECMAScript 2015 Support

Google has released version 4.9 of the V8 JavaScript engine, bringing it to 91% completion with ECMAScript 2015.

Developed for the Chrome browser, as well as being used on the server side by Node.js, the open source engine is currently in beta until the release of Chrome 49 Stable.

In the update for the V8 JavaScript Engine blog, project manager Seth Thompson wrote that "after years of development" Google's JavaScript engine V8 now ships with "a complete implementation of proxies" that are up to date with the ECMAScript 2015 specifications.

Thompson says

Proxies are a powerful mechanism for virtualizing objects and functions through a set of developer-provided hooks to customize property accesses. In addition to object virtualization, proxies can be used to implement interception, add validation for property setting, simplify debugging and profiling, and unlock advanced abstractions like membranes.

To proxy an object, you must create a handler placeholder object that defines various traps and apply it to the target object which the proxy virtualizes:

let target = {};
let handler = {
  get(target, name="world") {
    return `Hello, ${name}!`;
  }
};

let foo = new Proxy(target, handler);
foo.bar  // "Hello, bar!"

Significantly, Google's 4.9 release now covers 91% of the ES2015 spec, supporting default parameters as well as Proxy objects and destructuring. According to Dr. Axel Rauschmayer, author of Exploring ES6, "in locations that receive data (such as the left-hand side of an assignment), destructuring lets you use patterns to extract parts of that data."

Thompson says V8's 4.9 release support for destructuring of objects and arrays via patterns now comes from variable declarations, parameters, and assignments. He provides the example:

let o = {a: [1, 2, 3], b: {p: 4}, c: {q: 5}};
let {a: [x, y], b: {p}, c, d} = o;            // x=1, y=2, p=4, c={q: 5}
[x, y] = [y, x];                              // x=2, y=1
function f({a, b}) { return [a, b] }
f({a: 4})                                     // [4, undefined]

Also new to V8 4.9 is support for the sticky property on regular expressions, default values for function parameters, support for classes and lexical declarations outside of strict mode and an improvement in the implementation of Math.random().

With Node.js 5.5 currently using V8 4.6.85.31, the Node team have already begun integrating version 4.9. Contributor Michaël Zasso opened the issue create vee-eight-4.9 branch. He said:

The V8 team just cut the 4.9 branch so I started working on its integration.

That's still a work in progress but I'm creating the PR now because I have issues with a failing test and we will have to discuss about what we do with the V8 APIs that have been deprecated in 4.9 (as an example, I fixed the deprecation warning about String::NewFromOneByte here).

Rate this Article

Adoption
Style

BT