Functions in JavaScript
Functions in JavaScript
JavaScript
What is a function?
Parameters vs Arguments
Ways to implement a function
Function Declaration
Function Expression
Different types of function expressions
Named function expressions
Anonymous function expressions
Arrow function
IIFE
Higher Order Function
@adityauke
What is a function?
A function is a reusable piece of code that takes
some input, performs some tasks, and returns a
value. A function stores a piece of code that we want
to use repeatedly.
To use a function, we call that function by its name.
@adityauke
Parameters vs Arguments
When you define a function, the input values are
called parameters.
Parameters are something that is accepted by a
function.
@adityauke
Ways to implement a function
Function Declaration
While defining a function if the first keyword of the
statement is a function keyword, then it will be called the
function declaration.
Function Expression
While defining a function if the first keyword of the
statement is not a function keyword, then it will be called
the function expression.
@adityauke
Different types of function expressions
Named function expressions
@adityauke
Different types of function expressions
Arrow function
Arrow functions were introduced in ES6.
@adityauke
Different types of function expressions
@adityauke
Different types of function expressions
IIFE - Immediately Invoked Function Expression
@adityauke