JavaScript - question about function

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.

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

Thank you :slight_smile:

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