Posted on

A normal style function in JavaScript would look like this:

function sum(a, b) {
    return a + b;
}

But as this wonderful language servers everything as object, the following one is also acceptable

let sum = function(a, b) {
    return a + b;
}

Since programmers are lazy, the following one comes into being, which is called an arrow function

let sum = (a, b) => {return a + b;}

This is similar to lambda functions in other programming languages.

References:

  1. https://github.com/Bill0412/nodejs-server/blob/master/server.js
  2. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions

Leave a Reply

Your email address will not be published. Required fields are marked *