/*
In JavaScript, functions are first-class objects, meaning they can be assigned to variables,
stored in objects, passed as arguments, returned from other functions, and have their
own properties and methods.
*/
/*
* ============================================
* TITLE: Passing Function Objects as Arguments
* ============================================
*
* Functions can be passed to other functions,
* which enables flexible and reusable code.
*/
function performOperation(a, b, operation) {
return operation(a, b);
}
function add(x, y) {
return x + y;
}
function multiply(x, y) {
return x * y;
}
console.log(performOperation(10, 5, add));
console.log(performOperation(10, 5, multiply));
/*
run:
15
50
*/