JavaScript the Fun Part


effective-javascript-2

type-of-functions-2


Some other types of function in JavaScript

6. IIFE

We already know that IIFE means Immediately Invoked Function Expression..

It is the happening of declaration plus invocation at the same time.

So we declare and invoke the function right away.

For more see immediately-invoked-function-expression

7. HOC

A very useful and practical technique which is a kind of declarative interface for hiding our imperative code using a simple Inversion of Control mechanism.

For more see higher-order-functions

8. Callback

Register a function when the operation is asynchronous so we get the result of our registered function later on.

9. Arrow Function

New ES6 function that has no this binding.

When know that every JavaScript function has an implicit this binding. And it is referred to an object that calls that function.

With arrow function, if we assign it to an object as a property (we call this method); then this method has no access to this!

It is mostly useful for passing it around as an argument to a function and when we do not need to bind this.

10. Closure

Very powerful mechanism or technique or pattern that captures reference to the outer scope data / function for later use case or execution.

Closures are very useful and have many use cases like:

For more see get-comfortable-with-closure


Update: Thu Sep 05 2019 19:20:17 GMT+0430 (Iran Daylight Time)