Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Javascript isn't complicated but it does have some ugly boiler-plate. I would love to see C# style lambda's in Javascript.

C# style: var item_names = $( "li.menu_item span" ).map( x => x.innerHTML )

JS style: var item_names = $( "li.menu_item span" ).map( function( x ) { return x.innerHTML } )



CoffeeScript has C#-esque lambdas.

item_names = $("li.menu_item span").map (x) -> x.innerHTML


yeah, but the parser is messed up because it is whitespace sensitive. This would fail: compose (x)-> f(x) (y)-> g(y).


javascript 1.8:

$("li.menu_item span").map(function(x) x.innerHTML)

for that particular exaple, you could also steal pluck() from Prototype.js:

$("li.menu_item span").pluck("innerHTML")




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: