JS Functions
Arguments
Function has an arguments
object containing all of the arguments passed by the
called (even if function does not define any parameter, you can still pass
arguments).
Arrow functions do not have this parameter.
Arrow Functions
this
is inherited from the scope where arrow function was defined.
Functions’ Functions
call()
call()
allows to invoke any function in a context of any object.
If the function accepts arguments, we can pas them in via consecutive parameters
of call
.
apply()
Works like call()
, but it accepts parameters as an array instead of
consecutive parameters.
bind()
Creates a copy of a function in a context of some other object.
It doesn’t modify person1
nor person2
.
It can also be used to create a new function that used some preset argument value. I.e.:
Rest
It behaves like params
in C#. Rest can appear only at the end of the
parameters list.