Video – Various ways of creating a function in JavaScript

This video teaches you the various ways of creating a function in JavaScript. There are four ways a function can be created in JavaScript. They are as follows:

1. A function as a Statement
2. A function as an Expression
3. A function as an Arrow function
4. A function using Function constructor

 

https://youtu.be/1koTc_lhZLU

 

A function statement is hoisted at the top of the execution context. So, it can be invoked before it is created. In a function statement, primitive parameters are Passed as a Value and non-primitive parameters such that and object and an array are Passed as a Reference.

A function expression can be created without a name, whereas a function statement must have a name. A function expression is not hoisted on the top of the execution context, whereas a function statement is hoisted at the top of the execution context.

 

An arrow function does not have its own value of ‘this’ object


Discover more from Dhananjay Kumar

Subscribe to get the latest posts sent to your email.

Published by Dhananjay Kumar

Dhananjay Kumar is founder of NomadCoder and ng-India

Leave a comment

Discover more from Dhananjay Kumar

Subscribe now to keep reading and get access to the full archive.

Continue reading