is there any way to map the λ key to the function keyword?
so that these work:
var rFalse = λ() {
return false;
}
(λ(){
var str = "i'm in a closure";
}());
window.onload = λ() {
alert('window loaded');
}
I know that they are attempting to put a shortened function keyword in ecmascript v6, but I’m wondering if it is possible to do it now.
It is possible, just not natively. You’d have to look into implementing or using an existing DSL.
A good example could be CoffeeScript, which includes an Extras script for running on client-side via:
Their contents are converted to and reinserted into the document as JavaScript by:
However, keep in mind that client-side DSLs risk drastically increasing load times and ruining the user experience — CoffeeScript is primarily server-side for a reason.