JavaScript Fundamentals Functions

JavaScript fundamentals Functions


JavaScript Fundamentals Functions

1function name(parameter1, parameter2) {
2    /* code */
3}

ES6 Function Declaration with arrow syntax

1const functionName = (parameter1, parameter2) => {
2    /* code */
3}
Functions are the main “building blocks” of the program. They allow the code to be called many times without repetition.
Values passed to a function as parameters are copied to its local variables.
A function may access outer variables. But it works only from inside out. The code outside of the function doesn’t see its local variables.
A function can return a value. If it doesn’t, then its result is undefined.