Reputation: 2303
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.
Upvotes: 2
Views: 247
Reputation: 123503
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:
<script type="text/coffeescript">
Their contents are converted to and reinserted into the document as JavaScript by:
<script src="extras/coffee-script.js"></script>
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.
Upvotes: 2
Reputation: 138067
I wouldn't think so, since function
is a keyword... You'll have hard time passing your program through the parser.
Upvotes: 2
Reputation: 44078
JavaScript does not offer aliasing of keywords, so it is not possible make the syntax you're trying to use valid.
Upvotes: 8