Iulian Barbu Iulian Barbu - 4 months ago 28
Javascript Question

What means => used in this way in Javascript syntax?

I searched something on SO and run into this, which is a way to retrive a file from your local computer and use it in browser, with AngularJS.

.success((data) => console.log(data));

I wonder what this JavaScript syntax could mean:

(data) => console.log(data)

I don't know if is something AngularJS specific, but I mostly doubt so. Do you know more interesting tweaks which are no so common in daily use of JavaScript?


This is an arrow function: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions.

Arrow functions were introduced into JavaScript with ES2015.

Writing (data) => console.log(data) is equivalent to writing function (data) { console.log(data); }.