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

 

 

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

Leave a comment

Create a website or blog at WordPress.com