Tuesday, April 22nd, 2008
Talking about JavaScript 1.7, 1.8 and 1.9 before we get to 2.0
Is this JavaScript that would run in a current browser?
-
-
function square_of(x) x * x;
-
-
players.sort(function(x,y) y['score'] - x['score']);
-
Yup. This is JavaScript 1.8 and 1.7, also known as Pythonizing Javascript ;)
Tiago Silveira discusses these lambda expressions, as well as Generators:
-
-
function actions() {
-
for (f in document.forms) {
-
yield document.forms[f].action
-
}
-
}
-
list comprehensions, let:
-
-
function showItems(items) {
-
for (let i in items) {
-
// the variable i has the scope of this block.
-
ShowElement('item_' + i);
-
}
-
}
-
// Using comprehensions:
-
showItems([ i for ( i in obj ) if ( i> 3 ) ])
-
-
// Using generators:
-
showItems( i for ( i in obj ) if ( i> 3 ) )
-
And more.
Then we hear from John Resig that the JavaScript 1.9 planning meeting happened and we really hope for some SPLAT fun gets in as well as his own hope for built-in Function.prototype.bind and a native JSON encoder/decoder. Others were looking for setPropertyIsEnumerable, and Douglas Crockford has his own thoughts.












Sorry, am I being a bit slow. Is this post suggesting that the main browsers already support lambda expressions? FF3 does, IE7 doesn’t.
I got really excited for a moment.
Interesting, I agree with all of Douglas Crockford’s suggestions except the removal of eval() (it does have some valid uses). His ideas would really increase the power and usability of JS.
@kim3r: “a current browser” not “all current browsers” ;)
@Matt: roger that, makes sense now. Has anyone tried Lambda expressions in IE8?
Which current browser are you talking about? Firefox? :)
Also, make sure you specify the language as “javascript1.8″, not just “javascript”, or it won’t work in Firefox.