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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s