New features in this version:
Array comprehensions. One of my favorite features. It is already implemented natively in Firefox, but with the help of Mascara you can have it work in everything from IE 6 to Netscape 3 :-)
Example:
[x*2 for each (x in [1,2,3])]
evaluates to [2,4,6]
Destructuring assignments.
Example:
[a, b] = [1,2];
Assigns 1 to a and 2 to b. Very convenient.
2 kommentarer:
You are my HERO! Seriously, thank you so much. Having not heard anything since July, I feared the worst.
The List Comprehension is my favorite language feature of Python -- it will be SO NICE to have them (different name, slightly different syntax, but essentially the same thing) in Javascript.
By the way, any word on ECMAScript 3.1 and ECMAScript Harmony since Brendan Eich's announcement in August? It sounds like destructured assignment will make it into 3.1 -- do you know if array comprehensions will?
Thank you, Peter!
I will try to blog more regularly from now on.
At this point it is not totally clear what specific features will be included in 3.1 and Harmony.
It seems that 3.1 will not include new syntax apart from constants and getters/setters. So destructuring and array comprehensions will not be in the 3.1 spec.
Send en kommentar