D
D
DrunkMaster2018-02-19 15:23:12
JavaScript
DrunkMaster, 2018-02-19 15:23:12

What is this syntax called?

const a = () => {
  return 1;
}

And how to get 1 in this case? After all, the call
console.log(a);
Displays:
() => {
  return 1;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Egor Zhivagin, 2018-02-19
@DrunkMaster

What? This is not an assignment to a variable, but a declaration of a function a that returns 1
a()will print 1 to the console.
This is equivalent to this code:

function a () {
  return 1;
}

PS - it's called "arrow functions"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question