Declaration vs Expression
Declaration
function myFunction() {
console.log("hi");
}
Expression
const a = function() {console.log("hi")};
The Function Constructor : Function()
usage
const a = new Function("x", "y", "return x + y");
also possible without new
keyword
const a = Fuction("x", "y", "return x + y");
Function Hoisting
What is it? To call a function before declaring it.
myFunction();
function myFunction() {
console.log("hi");
}
Parameter vs Argument
function myFunction(name) {
console.log("Hi", name);
}
myFunction("Lena");
name is a parameter.
"Lena" is an argument.
Self-Invoking Function
What is meant by "self-invoking"? You don't need to call the function.
How to use? Put a function inside parentheses.
(function () {
console.log("hi");
})();
Top comments (0)