Is there a C#-like lambda syntax in JavaScript?

Lambda functions with similar syntax are included in ECMAscript 6, they’re known as “arrow functions”. An example:

["duck", "cat", "goat"].filter(el => el.length > 3); returns ["duck", "goat"]

There’s currently support in recent versions of Firefox and Chrome.

To use this syntax in JavaScript that’s targeting older browsers there are tools that can compile ES 6 to a more widely supported version – for example the tools Babel or Traceur.

Leave a Comment