const name = function(par1, par2){
// code
// return
};
name(par1, par2); // function call
const name1 = function(par){
// code
const name2 = function(par1, par2){
//code
// return
};
name2(par1, par2); // function call
// code
// return
};
name1(par); // function call
let name = function(){
// function 1
};
name = function(){
// function 2
};
function funcName(){
// code
// return
}
const name = (par1, par2) => {
// code
// return
};
1) ignores the extra arguments
const name = function(par){
// here we will get par1, and others have no effect
}
name(par1, par2, par3);
2) missing parameters will be undefined
const name(par1, par2){
// here par2 = undefined
}
name(par1);
but if we do - const name(par1, par2=2){ }. then par2 = 2, if it is not provided/
function name(par1){ // first function
let x = par1;
// code
return (par2) => { par1 * par2; } // second function
}
let name2 = name(par1); // now name2 holds the second function and it has also the value of par1 given into first function.
name(par2); // now we can call name2 and it will also use the previos given parameter par1.