Automotive
Improved ECMAScript 2015 (ES6) support
V8 4.5 adds support for several ECMAScript 2015 (ES6) features.Arrow Functions
With the help of Arrow Functions it is possible to write more streamlined code.1 | let data = [0, 1, 3]; |
The lexical binding of 'this' is another major benefit of arrow functions. As a result, using callbacks in methods gets much easier.
1 | class MyClass { |
Array/TypedArray functions
All of the new methods on Arrays and TypedArrays that are specified in ES2015 are now supported in 4.5. They make working with Arrays and TypedArrays more convenient. Among the methods added are Array.from and Array.of. Methods which mirror most Array methods on each kind of TypedArray were added as well.Object.assign
Object.assign enables developers to quickly merge and clone objects.1 | let target = {a: "Hello, "}; |
This feature can also be used to mix in functionality.
More JavaScript language features are “optimizable”
For many years, V8’s traditional optimizing compiler, Crankshaft, has done a great job of optimizing many common JavaScript patterns. However, it never had the capability to support the entire JavaScript language, and using certain language features in a function—such as “try/catch” and “with”—would prevent it from being optimized. V8 would have to fall back to its slower, baseline compiler for that function.One of the design goals of V8’s new optimizing compiler, TurboFan, is to be able to eventually optimize all of JavaScript, including ECMAScript 2015 features. In V8 4.5, we’ve started using TurboFan to optimize some of the language features that are not supported by Crankshaft: ‘for-of’, ‘class’, ‘with’ and computed property names.
Here is an example of code that uses 'for-of', which can now be compiled by TurboFan:
1 | let sequence = ["First", "Second", "Third"]; |
Although initially functions that use these language features won't reach the same peak performance as other code compiled by Crankshaft, TurboFan can now speed them up well beyond our current baseline compiler. Even better, performance will continue to improve quickly as we develop more optimizations for TurboFan.
V8 API
Please check out our summary of API changes. This document gets regularly updated a few weeks after each major release.Developers with an active V8 checkout can use 'git checkout -b 4.5 -t branch-heads/4.5' to experiment with the new features in V8 4.5. Alternatively you can subscribe to Chrome's Beta channel and try the new features out yourself soon.
Posted by the V8 team