ECMAScript 6 in WebKit
ES6 brings a lot of new and interesting language features to JavaScript. ES6 has learned from many of JavaScript’s past mistakes and has crafted new language features that have clearer and easier to understand semantics. let
and const
are examples of this; they are block scoped declarations and thus not prone to the common errors caused by misunderstanding var
scoping semantics. ES6 also includes features that are designed to make common JavaScript idioms feel more natural. As an example, arrow functions make it easy to write small functions that have a lexically bound this
; something JavaScript programmers do quite often. class
syntax makes it easier to write classical object oriented code that is commonplace in many programs. Destructuring syntax helps remove boiler plate that is found in any sufficiently large JavaScript program. We on the WebKit team are really excited about ES6 and have been working hard on implementing it. In Safari 9 for OS X and iOS 9 you’ll be able to use some great ES6 features:
- Classes
- Promises
- Map, Set, WeakMap, WeakSet, for…of loops
- Symbols
- And other great features
There are even more ES6 features you can try out if you run the latest WebKit nightly build. We’ve recently implemented:
let
,const
, andclass
block scoping- Much of the Reflect API
- A large part of the current module specification
- Tail calls
- Default parameter values
- Default destructuring values
- Arrow functions
- Some of the internationalization API
- And much more
If you’re interested in following our ES6 implementation and trying out ES6, download a WebKit nightly build. You can also help us fix any bugs in our current implementation by reporting any bugs you find. Also, if you (yes, you, the reader) are interested in adding any ES6 features to WebKit or even just fixing a few bugs, I’d be more than happy to help you get started. You can get in touch with me on twitter: @saambarati. And as always, you can get in touch with @jonathandavis with any other questions.