BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Preview the Next JavaScript in Google Chrome

Preview the Next JavaScript in Google Chrome

Leia em Português

This item in japanese

Google Chrome and V8 now support some of the features planned for the next version of JavaScript, known as ECMAScript 3.1 “Harmony”. To try out these features you can use dev channel release of Chrome with the “Experimental JavaScript features” flag turned on.

The features being highlighted in the Google press release are:

Lexical scoping. Now "let" is the new "var" – traditional "var" declarations are complemented with "let" and "const". Both are properly block-scoped bindings, eliminating a common source of errors and weird behaviour. Function declarations are now officially allowed in local scope as well, and also obey lexical scoping. (Note: Lexical scoping is only available in ES strict mode.)

Collections. Efficient maps and sets will make your life easier. Any value can be used as a key or element, including objects. No surprises, no more need to abuse objects as dictionaries. (Caveat: Iteration over collections is not yet specified.)

Weak maps. A special kind of map for which the garbage collector determines when a key is no longer reachable, so that the key-value pair can be removed from the map automatically. This goes a long way towards avoiding memory leaks in long-lived tables and relieves the developer from worrying about stale entries.

Proxies. A proxy simulates a JavaScript object or function, and can customize just about any aspect of their behaviour that you can imagine. This is a real power feature, that takes reflection to a new level and can be used to implement various advanced abstractions and interfaces.

Other features being considered for JavaScript include modules, iterators, and generators.

Rate this Article

Adoption
Style

BT