//function declaration
function calcAge1(birthyear){
return 2037- birthyear;
}
//function expression
const calcAge2 = function(birthyear){
return 2037- birthyear;
}
NOTE -> When passing arguments to a function -> for a primitive type only the value is passed but for an object the reference itself that is the whole object itself is passed and so an object carries the changes what a function makes in it.
Function
Call and Apply Methods
Here after storing the book method of lufthansa object in book constant it behaves as a function outside that object and for the this method to access the object whose values are needed in that function we use the .call function.
Higher Order Function:
Higher-order function is a function that accepts another function as an argument or returns a
function as a return value or both.
const firstOrderFunc = () => console.log ('Hello, I am a First order function');
const higherOrder = ReturnFirstOrderFunc => ReturnFirstOrderFunc();
higherOrder(firstOrderFunc);
First Order Function:
First-order function is a function that doesn’t accept another function as an argument and
doesn’t return a function as its return value.
const firstOrder = () => console.log ('I am a first order function!');