0

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.

this.http.get(<path_to_your_json_file>)
 .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?

Iulian Barbu
  • 61
  • 11

1 Answers1

0

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); }.

Ben Cook
  • 1,654
  • 2
  • 18
  • 32
  • 2
    Please [avoid link only answers](http://meta.stackoverflow.com/tags/link-only-answers/info). Answers that are "barely more than a link to an external site” [may be deleted](http://stackoverflow.com/help/deleted-answers). – Quentin Nov 20 '16 at 21:43