InfoQ

InfoQ

News

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

Preview the Next JavaScript in Google Chrome

Posted by Jonathan Allen on Feb 13, 2012

Sections
Development
Topics
Javascript ,
Web Development ,
Dynamic Languages ,
Languages ,
Programming ,
Google V8 ,
EcmaScript Harmony ,
Chrome ,
Standardization ,
ECMA

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.

ECAMScript 3.1 should be ECMAScript by Alen Milkovic Posted
  1. Back to top

    ECAMScript 3.1 should be ECMAScript

    by Alen Milkovic

    I think this is a typo