It is a mechanism where functions and variables declarations are moved to the top of their scope before execution of the code. Hoisting allows the functions to be used in code before they have been declared.
Currying is a method to transform the functions with multiple arguments into multiple functions of a single argument in a sequence.
In simple words, a function takes the first argument and returns a new function simultaneously it takes the second function and returns a new function and then takes the third one and the process keeps on going until it fulfills all the arguments.
Currying helps to create high-order functions in event handling.
Polymorphism is one of the key concepts for any object-oriented programming. Its use of it is to display a message in more than one form. It is the practice of designing the objects to share behaviors and override shared behaviors with specific ones and for it, polymorphism takes advantage of inheritance to make it happen.
In the above program prototype-based method for people, the constructor function has to override by another prototype function to return the Name as uppercase.
A promise is an asynchronous function. The promise object represents the eventual completion of a synchronous operation of an asynchronous operation and its value. It can be used to avoid chaining callbacks.
A promise can be one of the below states:
pending: initial state, neither rejected nor fulfilled.
fulfilled: the operation was completed successfully.
rejected: the operation is failed.
5. Async & Await
Async and Await make promises to write easily.
In JS asynchronous patterns can be handled in different versions like below:
in ES5, it is done by "Callback"
in ES6, it is done by "Promise"
in ES7, it is done by "async & await"
Many programmers have a misunderstanding about async & await, but they are promises only. Every async function returns a promise. The await can only be used inside an async function and everything that you will await will be a promise.
In order to know about async and await the programmer should have a proper understanding of the promises. If you can understand async & await, it will help you to implement functional programming easily and will increase the readability of code.
Please do let me know how you like this blog and also let me know if you’re interested in specific kind of blog, Thanks.