Promise in JavaScript
Hello guys, sorry to disturb you all; I'm learning about promises in JS... can someone just check if my understanding is correct and what you guys can add/pinpoint on this concept please.... here is what I've understood so far:
Previously, we used to make use of callbacks to perform sequential execution but this can lead to code being really difficult to understand. Now, with the use of promise, we no longer need callbacks.
In order to use a promise, we need to create and return a promise object using the following syntax:
Say we have 4 functions and we need to execute them sequentially, we can now do what is know as method chaining, like this:
func_1.then(func_2).then(func_3); ect
Please do correct me where I'm wrong... there are things still a bit unclear in my head but I understood the concept overall
Previously, we used to make use of callbacks to perform sequential execution but this can lead to code being really difficult to understand. Now, with the use of promise, we no longer need callbacks.
In order to use a promise, we need to create and return a promise object using the following syntax:
Say we have 4 functions and we need to execute them sequentially, we can now do what is know as method chaining, like this:
func_1.then(func_2).then(func_3); ect
Please do correct me where I'm wrong... there are things still a bit unclear in my head but I understood the concept overall
