Function Expressions in JavaScript
What are Function-Expressions? A Function-Expression is a function that is assigned to a variable or a property of an object. It can be named or anonymous. It is a function that is created at runtime and can be passed as an argument to another function. //example of a named Function-Expression let square = function ( num ) { return num * num ; } ; //example of an anonymous Function-Expression let add = function ( a , b ) { return a + b ; } ; How are Function-Expressions used? Function-Expressions are commonly used for following purposes: 1. To create and assign a function to a variable or property of an object. 2. To create a closure, i.e., functions within functions that can access the outer functions' variables. 3. To pass a function as an argument to another function. 4. To return a function from another function. //example of a Function-Expression used to create a closure function outerFunction ( x ) { function innerFunction ( y ) { re...