What is the difference between method declarations?

  • 0
    methodName () {code; }

    methodName = function () {code; }
    JavaScript Anonymous, Aug 14, 2019

  • 2 Answers
  • 0
    In nothing

    This is an abbreviation introduced in ES5.

    methodName () {code; }

    P.S. Probably not equal, but :

    methodName: function () {code; }

    Otherwise, this is not a method))

  • 0
    This is just an alternative syntax for declaring a function!

    Function Declaration is a function declared in the main flow of code. (First Option)

    Function Expression - a function declaration in the context of an expression, such as an assignment. (Second option)

    The main difference is that the first version of the function is created before the code is executed, the second after execution

    This means that we can call the first option wherever we want, before or after. The second option can be called only after its declaration.

    Like so

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!