Syntax difference


#1

During the functions course in codeAcademy we learn:

const variableName = () = >

However, when I google functions javasscript I often find this:

function variableName(n)

Will this be covered in future exersises? And if not, why / how is this different?


#2

look at this documentation:

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

it explains the two ways we can declare functions: Function expressions and Function declarations

You can read about them.

const variableName = () = > is a function expression, where as function variableName(n) is a function declaration. When to use which, is up to the developer. Learn there differences

to make matters more complicated (simple things are boring), you use es6 (the latest version of javascript) which allows to shorten is the function expression (among other things)


#3

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