Assign function
examples/functions/assign_functions.js
"use strict"; var add = function (a, b) { return a+b; } var sum = add; console.log(add(2, 3)); // 5 console.log(sum(3, 4)); // 7 console.log(sum); // [Function] // function add(a, b) { // return a+b; // }
We can assign the name of a function to a variable. Now we have the same function with two names. We can call both using the function_name() notation. We can even print the source code of the function in either of the variables.