JavaScript Functions

12/8/20 functions

What are the three ways to syntactically write a function? What are the differences in how the function acts?

There are arrow functions, function expressions, and function declarations. An arrow function is shorter and do not create their own this value. Function expression defines a named or anonymous function these cannot be hoisted. Finally function declarations these only are named functions and are hoisted.

What is the difference between parameters and arguments?

Parameters are used to help define a function, parameters, they help to further define the function. Arguments however, are what the function receives from the parameters upon execution. The two need to both be present in order for them to have any value.

What are higher order functions? can you provide an example?

When a function has another function as a parameter this is considered a higher order function. One of the examples provided was the Array.prototype.map which “creates a new array populated with the results of calling a provided function on every element in the calling array.”