Programming Tips - javaScript: How to use lambdas / arrow functions

Date: 2018mar31 Update: 2026jul4 Language: javaScript Q. javaScript: How to use lambdas / arrow functions A. Arrow functions (=>) are a light weight replacement for anonymous functions. For example:
const squareOld = function(x) { return x * x; } const squareModern = x => x * x; console.log(' old=' + squareOld(10)); console.log('modern=' + squareModern(10));
They're an expressive short form. Now, all browsers support them. More examples: https://googlechrome.github.io/samples/arrows-es6/