JavaScript - question about function


#1

Hi,

I am new to this Community and quite new to JavaScript.
I appreciate good quality of the e-course and the way of the detail and reasonable explaining.
So thank you.

I would like to ask - I came across two ways of declaring a function - see below.
It seems, that the 1) is easyier. I would like to ask, which advantages has the 2) type of declaration.

  1. function takeOrder() { …
    X
  2. const takeOrder = (topping, crustType) => { …

Thank you for answer.

Libor.


#2

function declaration vs function expression is what you are looking for, MDN has a good article about it:

https://developer.mozilla.org/nl/docs/Web/JavaScript/Guide/Functions


#3

Thank you :slight_smile:


#4

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