What is this in JavaScript

Hi guys,

I’m studying JavaScript and I found something like this:

() => {
    console.log("handler information");
}

So what the code above is called. I understand that it would print out “handler information” on the console.
But what is it? How it would be use. I found it as a part of something like this:

navigator.requestPermission({argument1, argument2}).then(
  () => {
  }
);

Thanks,

That’s the fat arrow syntax from ES6 or ES2015 as it’s now known.

That’s an arrow function expression, which is similar to an anonymous function but with a more compressed syntax.

Hi Paul,

Thank you so much. I’ll learn more about it.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.