a function can be assigned to a variable in javascript code example
Example 1: declare function javascript
function myFunction(var1, var2) {
return var1 * var2;
}
Example 2: Object as a Function
const profileUpdate = ({ name, age, nationality, location }) => {
}
Example:
const stats = {
max: 56.78,
standard_deviation: 4.34,
median: 34.54,
mode: 23.87,
min: -0.75,
average: 35.85
};
const half = ({ max, min }) => (max + min) / 2.0;
console.log(half(stats));
Example 3: js store function in variable
var foo = function(a){ return a * 2; }
var bar = foo(2);
foo = function(a){ return a / 2; }
bar = foo(bar);