Introduction to Functions


#1

Hi, I don’t understand the syntax in bold. Can someone explain the meaning?
I understand the const and pressPowerButton, but what is the meaning of = () => ?

const pressPowerButton = () => {
if (calculatorIsOn) {
console.log(‘Calculator turning off.’);
calculatorIsOn = false;

Thanks in advance.


#2

its the arrow function:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions

this might be slightly easier to read:

https://www.sitepoint.com/es6-arrow-functions-new-fat-concise-syntax-javascript/


#3

I see, just like lambda.
The mozilla link is kinda confusing, but the second one explains very well.

Thanks again. :slight_smile:


#4

Actually, the mozzila one is really good and thorough but more difficult to read.


#5

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