What’s a feature?
A function is a sub-program for the performance of a specific task.
When called, functions are executed. This is regarded as a role invoking.
Values can be used and transferred to functions within the function.
It is objects that are functions.
Defines a function.
A function expressions describe a variable that is called or anonymous. The anonymous function is a non-named function. Function expressions are not hoisted and can not therefore be used before describing them. We set the anonymous type object equal to a variable in the example below.
An Arrow Function Expression is a shorter syntax for writing function expressions. Arrow functions do not create their own
Parameters vs. Argum
In defining a function, parameters are used, they are the names generated in the function specification. In fact, we can pass up to 255 parameters in a function definition! Separate parameters
Arguments, on the other hand, are the values the function receives from each parameter when the function is executed (invoked). In the above example, our two arguments are
Invoking a Function.
When the function is called, functions are executed. This method is referred to as an invocation. By referencing the name of the variable, you can invoke a function, preceded by an open and closed parenthesis:).
Let’s look at an example.
If you are using Google Chrome, open your dev console to code with the following examples:[ WINDOWS]: Ctrl + Shift + J[ MAC]: Cmd+ Opt + J First, a function name will be defined.
To invoke our function, we call it, while passing in the singular parameter. Here I am calling this function with the name Aadil 808:
If your function has no parameters, an empty array of parentheses can be used to invoke it:
undefined unless otherwise specified.
Let’s test this by creating and invoking an empty function:
Awesome, as expected,
undefined is returned.
Now, we can customise what is returned in our function by using the
return keyword followed by our return value. Take a look at the code below:
It is called a higher-order function when a function accepts another function as a parameter or returns a value. You’ve got it