##A function is similar to objects##
- A function is an instance of the Object type
- A function can be stored in a variable
- A function can be passed as an argument to another function
First class function?
##Passing a function as an argument##
var numbers = [1,4,6,1,9]
function arrayCalc(arr,fn){
var arrRes = [];
for (var i = 0; i < arr.length; i++){
arrRes.push(fn(arr[i]));
}
return arrRes;
}
function calculatePower(num){
return num**2;
}
//Calculate power without brackets since it is a call back function
arrayCalc(years,calculatePower);