2

upon reading the latest NodeJS docs I encountered a new way of declaring a function:

fs.unlink('/tmp/hello', (err) => {
  if (err) throw err;
  console.log('successfully deleted /tmp/hello');
});

Source: https://nodejs.org/api/fs.html#fs_file_system

Now I want to know how this (var) => { <functon-content> } type declaration is called, so that I can research more on it.

I have not yet found anything online regarding this topic. :(

T4cC0re
  • 81
  • 1
  • 9
  • 1
    ECMA6 function declaration : https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions. Please research around before posting such questions. – NiRUS Jan 15 '16 at 18:03

1 Answers1

4

It's a feature of the ECMAScript 6 called Arrow Function: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions

An arrow function expression (also known as fat arrow function) has a shorter syntax compared to function expressions and lexically binds the this value (does not bind its own this, arguments, super, or new.target). Arrow functions are always anonymous.

Shomz
  • 37,421
  • 4
  • 57
  • 85