Promises | Ep 02 Season 02 - Namaste JavaScript
Promises is the new way of handling asynchronous operations in JavaScript. This episode of Namaste JavaScript Season 2 will explain how Promises work in JavaScript along with code examples in detail.
00:00 - Introduction
00:50 - Code Example of Callbacks and Promises
08:05 - Promise.then function
09:30 - Callbacks vs Promises
11:23 - Importance of Promises
12:22 - Promise Object in Browser
15:58 - Deep dive into Promise States
21: 52 - Promise Interview Question
25:20 - Promise Chaining in JavaScript
30:13 - Common mistake while Promise Chaining
33:17 - Recap of the video
36:22 - Teaser of the Next Video
37:11 - Homework of this episode
38:32 - Thank you for watching Namaste JavaScript 🙏
If you find this video helpful,
Please support me by giving a Super Thanks contribution to the video ♥️
If not by money,
you can also support this video series, by sharing it with your friends on Social Media. 🙏
I'll give my best to come up with great content and everything absolutely for free on KZread. 😊
Also, give it a thumbs up and subscribe to my channel for more such videos. 🔔
Link to Subscribe: kzread.info...
Cheers,
Akshay Saini
akshaysaini.in
Stay Connected:
LinkedIn - / akshaymarch7
Facebook - / akshaymarch7
Instagram - / akshaymarch7
Twitter - / akshaymarch7
#NamasteJavaScript #AkshaySaini
Пікірлер: 2 200
Your teaching will have a huge impact in the world. I'm grateful for the time and energy that you put in to make such complex Javascript concepts simple. Thank you 🙏
@akshaymarch7
Жыл бұрын
Thank you so much for supporting my channel. This means a lot. ❤️
@ayushi8412
Жыл бұрын
currently I am pursuing mca from ignou (open) and before that I have done bsc mathematics .I am fresher .I wants to work at top companies.many of friends are telling with these degrees I cant join top mnc as they dont give preference to open degree .I am very much frustrated .is it TRUE?
@prathamjaiswal1082
Жыл бұрын
@@ayushi8412 Ayushi actually your degree doesn't matter I myself is currently doing BCA and will do MCA in the future and I also have heard these opinions of people that you won't get a job if you're doing MCA or having a open degree but what I have seen and learned is that in today's world the top companies seeks skills over degree soo if you have really good skills then you will definitely get a job in top companies, Hope this helps :)
@royalbandadancer
Жыл бұрын
@@ayushi8412 No
@ganeshpatil6020
Жыл бұрын
@@prathamjaiswal1082 I have done the MCA and I don't think it made any difference in my career. I would have grown my career for 3 more years if I had searched for a job after BCA and might have become a team leader today. not a single interviewer asked about my MCA academics
1. Before promise we used to depend on callback functions which would result in 1.) Callback Hell (Pyramid of doom) | 2.) Inversion of control 2. Inversion of control is overcome by using promise. 2.1) A promise is an object that represents eventual completion/failure of an asynchronous operation. 2.2) A promise has 3 states: pending | fulfilled | rejected. 2.3) As soon as promise is fulfilled/rejected => It updates the empty object which is assigned undefined in pending state. 2.4) A promise resolves only once and it is immutable. 2.5) Using .then() we can control when we call the cb(callback) function. 3. To avoid callback hell (Pyramid of doom) => We use promise chaining. This way our code expands vertically instead of horizontally. Chaining is done using '.then()' 4. A very common mistake that developers do is not returning a value during chaining of promises. Always remember to return a value. This returned value will be used by the next .then()
@mindblowing2895
Жыл бұрын
Great share ❤
@vivekbhatt3932
Жыл бұрын
ok
@niharikakesarwani8290
Жыл бұрын
aani
@vivekbhatt3932
Жыл бұрын
@@niharikakesarwani8290 ok
@richochet
11 ай бұрын
This is so helpful, thank you.
Before promise we used to depend on callback functions which have two disadvantages 1.) Callback Hell (Pyramid of doom) 2.) Inversion of control 1) Inversion of control is overcome by using promise promise is object represent the eventual completion of asynchonous operation a)A promise has 3 states: pending | fulfilled | rejected. b) As soon as promise is fulfilled/rejected => It updates the empty object which is assigned undefined in pending state. c) A promise resolves only once and it is immutable in nature. d) Using .then() we can attached the cb(callback) function. 2) - To avoid callback hell (Pyramid of doom) => We use promise chaining. This way our code expands vertically instead of horizontally. Chaining is done using '.then()' - A very common mistake that developers do is not returning a value during chaining of promises. Always remember to return a value. This returned value will be used by the next .then()
I like the definition that it’s a placeholder for an asynchronous operation. I like that you are focusing on what to say in an interview because that is why I am watching these videos for review of many things
Watch Next Episode - kzread.info/dash/bejne/h2topKycopu0lbQ.html This Episode is a little long, but trust me everything taught is super important. Watch this video with full attention and also finish the homework given at the end of this video. All the Best. Keep Rising! 🚀
@lakshyapant5225
Жыл бұрын
bro thanks a lot.....lots of love.....❤❤❤❤❤❤❤❤
@BlackZero880
Жыл бұрын
Bro we can bear with you even 1hr long...You never disappoints us🙂
@codingcinemax
Жыл бұрын
It was really amazing as previous videos. One of the best explanation on KZread.
@manishraj4075
Жыл бұрын
Hello Akshay Sir, your explanation is very great and very useful, I am fresher in javascript and I want to learn javascript can you tell me how to start?
@YouCanPlayPiano
Жыл бұрын
- What is promise? Promise is an object, which represents eventual completion of async operation. - Why promises are important? promises are important because 1. Promises guarantee you that callback functions are called whenever they have response with them. Javascript guarantees you that callback functions are called 100%. 2. Promises guarantee you that callbacks are called once. So like traditional callbacks these are not called multiple times or not at all. 3. It provides us full control of code, so we don't need to handover or depend on external function.
1. What are Promises? Promises are objects which are used to perform asynchronous operations. They are just like placeholders to store a future value that will be returned after some time. They contain two properties: PromiseState and PromiseResult. 2. Importance of Promises: a) Promises can help us to write trust worthy code. b) Promises are used to solve the problems of callbacks like inversion of control and callback hell. c) They give us the result prompt in three states: 1) Pending 2) Fulfilled 3) Rejected d) We can attach function to promise object and retrieve its value unlike callbacks no need to pass the function. e) Nesting can be done in Promises and with the help of that we can return the values in each individual chain. Thank you bhaiya, for this awesome explanation of Promises.
@prasadmadushan
Жыл бұрын
You might add to list -> promise result is immutable
@ayushi8412
Жыл бұрын
currently I am pursuing mca from ignou (open) and before that I have done bsc mathematics .I am fresher .I wants to work at top companies.many of friends are telling with these degrees I cant join top mnc as they dont give preference to open degree .I am very much frustrated .is it TRUE?
@faizanahmed9304
Жыл бұрын
@@ayushi8412 If you can master CS topics like DSA, DBMS or OS then you can still apply to top MNC's
@shaikwaris4131
Жыл бұрын
@@ayushi8412 hii what are you doing now?
God wants this guy to teach people. Greetings from Russia❤
1) A Promise is an object that represents the eventual completion or failure of an asynchronous operations. 2) Importance of promise is that we do not loose the control of the program, a promise object is immutable and can be send anywhere without worrying about changes, also it resolves only once either to success or failure.
Length is not at all a issue, rather it's a blessing it means the video is loaded with lot of awesome content. Thank you so much for all your efforts
@akshaymarch7
Жыл бұрын
♥️
@rajankhunt7002
Жыл бұрын
@@akshaymarch7 which font family use in this video plz send reply
@rajankhunt7002
Жыл бұрын
if you know which font family use in this video plz send reply
@VimalKumar-ts7xn
Жыл бұрын
@@rajankhunt7002 menlo
@sagargondage550
Жыл бұрын
#masai
Love the way you explain the topics with so much passion. Grateful for your videos 🙏🙏
@akshaymarch7
Жыл бұрын
Thank you so much for supporting my channel, Kamalendu. This means a lot. ❤️
Every time I have problem in JS, I come to this channel and If I find it in namaste video title I know that after watching it I will have 100% understanding of the subject which won't be a problem anymore. Thanks a lot
Promises is an object that represents the eventually completion or failure of an asynchronous operations. Disadvantage of callback - Callback Hell (Pyramid of DOOM) - Inversion of Control (Lost the control over the code) We overcome the Inversion of control by using promises, You are amazing teacher and explained complex things in beautiful / simple way. Thank you so much🙏
Promise is an object that represents the eventual completion of an asynchronous operation. Promises are immutable so it can't be altered as a result it helps to get rid off inversion of control that would be occurred in case callback and by chaining of promises we can get out of the callback hell. In chaining of promises we should use return to get the promise result so that we don't miss anything from the chain. Thank you sir for your efforts it's just like charity (good deeds ) and God will bless you for this selflessness.
Before watching this video, my state for concept promise was PENDING, but now I can definitely say its much better than RESOLVED 😄 Hats off for detailed discussion, it was a GEM.
A Promise is an object which represents eventual completion or failure of an asynchronous operation. Promises are immutable once resolved and they give us a lot of control over our code. They have three state pending, fulfilled or rejected. The promise object contains two parts 1) PromiseState(stores the sate of the prmise) and 2)PromiseResult(stores data)
A promise is an object, which represents that, mentioned Asynchronous operation will eventually be completed. Thanks Akshay for the courses which promise us to make our life much easier❤❤
Thanks! Your videos are helpful in understanding and loving javascript and in career. A small contribution from my side for your huge efforts.
@akshaymarch7
8 ай бұрын
Thank you so much for supporting my channel. This means a lot. ❤️
@abhishekkumar-fe8lw
4 ай бұрын
aur 900 rupe kero fir pin hoga tumhara comment
@RajneeshYadav-yl2th
2 ай бұрын
@@abhishekkumar-fe8lw tum to wo bhi nahi kiye,, tumhare liye bhi hai option 40 ka agar 40 rupay bhi ho account me to wahi kr dena.😂😂
I am a civil engineer. I searched and purchased so many courses but none of them taught me the way you did. Thank you for making my transition to this field so smooth.
Promises are important because they help us avoid the problems we face with callbacks, namely inversion of control and callback hell. Also, promises, once resolved are immutable; thus building up immense trust. Promises are very beautiful.
Promise is an object that represents eventual completion or failure of an asynchronous event. Advantages of promise are: 1. Promise eliminates the problem of Inversion of Control as in case of call backs. 2. Promises brings lot of trust in the transaction. 3. We can avoid callback hell by attaching callbacks to promise chains in vertical fashion. Thank you Akshay for this wonderful and knowledgeable video 🙏
Heyy Akshay. As much as the content is presented so beautifully, the excitement with which you explain the stuff shows how much you love Javascript and how much you love teaching it. There's always so much to learn from you, and that's not just Javascript. Great job!!
A promise is an object that represents an eventual completion of an asynchronous operation. We use it to avoid inversion of control and call back hell. Thank you so much to explain it in a very pleasant way.
Well explained. Just saw your first video and I am blown away by the way you have dig in deep to explain every single detail. Looking forward to check out more of your videos
@akshay saini bhai, one thing that keeps your videos watchable again and again is the little humor that you add.
That thumbnail, that eagerness to teach, that content, everything is awesome 🔥. You are literally a god in JavaScript teaching 🙏
Thanks from bottom of the ❤, explaination dil chu liya, keep it up... Eagerly waiting for next episode.
@akshaymarch7
Жыл бұрын
Thank you so much for supporting my channel, Abhishek. This means a lot. ❤️
I love the way you teach, before your promise tutorial i was not able to summarise promise after your tutorial i am not able to forget promise, now the definition:- Promise are object that represent the eventual completion or failure of asynchronus operation.
Awesome Series! I am not a huge fan of watching courses, but I was really blown away. And I did learn the definition of a promise. -> A promise is an object which is a representation of eventual completion and rejection of an async operation. -> We use promises because it prevents us from callback hell and inversion of control. By the introduction of .then() (promising chaining) we have control over our program. Because when we use .then() we attach a callback function to it and don't pass a callback function in it, so we have control of our program/function.
Promise is an object representing an eventual success or failure of an asynchronous process. Promise is immutable, it cant be changed hence secure, it resolved callback hell problem, Thank you for such a deep conceptual knowledge sharing Akshay :)
Hi Akshay, I think not me, every developer are waiting for your videos so that we get a clear picture of JavaScript. Thank you so much for your knowledge
@yoursaesthetictrie2438
Жыл бұрын
Yes,
your explanation was very nice to listen and understand what you are tolding for us 1.Promise is an object which represents eventual complition of an async operation 2.Managing miltiple asyncronous operations and preventing callback hell and unmanageable code
First of all, Thank you Akshay for your hard work to explain JS in a easy and understandable way, coming to the HW you gave: A promise is an Object which represents an eventual completion of an async operation. The Big advantage is that we can be rescued from the callback hells and also we have the control of the programme. Also promises helps us to resolve the issue of Inversion Control and we can have the programme in a chaining way using the then method.
The excitement you show to explain us is remarkable! ☺️❤️ Please continue the pace. 😊😁
There is absolutely no doubt that you are the best when it comes to the explaining any topic. If someone go through Namaste JS season 1 and 2 then they can crack any tech interview for sure. Thanks a lot for this initiative and making us fall in love with JS. Only one complaint, the gap in between release of 2 videos is little longer. We all became so eager for your next video but this gap haunts us. If you can do something with it, it will be very good Thanks again. God bless you with lot of success in your life
Hi Akshay, you really have teaching skills for granted, this is how a good teacher exactly is. Thank you so much for your dedications to teach and help others. Love from Lahore, Pakistan
Promise is an object representing the eventual completion or failure of an asyncronous function. As trust is the core of relationships, promises provide trust from an async function to an object. Promises can only be resolved once and promise objects are immutable. We could avoid the callback hell(pyramid of the doom) by writing codes in promise. In callback functions the the functions are passed inside another function, where the complete responsibility of fn depends on the web api(aka inversion of control) or other fn where as in promise the callback functions are attached to the web api. finally trust is everything. Great work akshay . Thanks a lot
Your energy is unparalleled. Hands down the best content on youTube. Thanks you for making 'Promises' so much easier and fun!
A promise is an object hat represents the eventual completion of an asynchronous operation. What an explanation.. you are a gem for many learners!!
Promise is an obejct thats represents the eventual completion of an asyn operation. Thanks to you, I learned JS more deeply now that I love Javascript
I love the way you explain the complex stuff so easily and literally enjoy while doing it :)
No one can beat your lecture content , passion of teaching, your energy Dope content as always 🔥🔥🔥
Thank you very very much for this series. Literally falling in love with JavaScript by getting to know it better.😍 Was waiting for this video for a long time.😭 Please async-await next.🙏
Excellent explanation and tutorial. I'm confident that everyone can comprehend Promise if they pay close attention. An excellent Promise tutorial.
had watched many video on Promises but no one had explained better than you... great video
What is Promise? Promise is an object that represents eventually completion of async() operation. Importance of Promises: Trust worthy, Inversion of Control(IOC),Promise chain, States(Pending, Fullfilled, Reject) Thank you so much brother for an awesome explanation ❤
We need more tutorials from experts like you. How I wish there's some standards for tutorial videos on this platform so people won't waste their time. Would you care to create a ReactJs series? It excites me to see how you will deep dive into each topic. Please keep it up and don't be conscious with time. We appreciate your work man! Assignment: My understanding: Promise takes output of a function as undefined obj(as a container value)to be assigned actual output values at a later time. This allows for a guaranteed execution of a callback in an ASYNCHRONOUS OPERATION. Definition: Promise is an obj representation of an eventual completion or failure of an asynchronous operation:)
First time visiting your channel. Instantly fallen in love, the way you are teaching is amazing. Promise are special object which represnts eventual completion or failure of async operation. Pros 1. Avoid Inversion Of control 2. Avoid callback hell 3. Create vertical chaining instead of horizontal chaining 4. Instead of passing the callback function we attach the call back function 5. Guarantee provided by JS that callback will be executed once promise is fulfilled and it be executed only once
bro your explanation is the purest form of simplicity
ohhh man i cant believe it i watch the whole 39 minute video without a single pause. Seriously love it
@akshaymarch7
Жыл бұрын
♥️
Hello Akshay bhaiya, I have completed 💯 % of namaste JS session 1, and my confidence level is very high, now I am fall in love ❤ of JavaScript, Eagerly waiting for promise and async awaits. I am thinking can you start a new series of DSA along with JS so it is very helpful, as you are teaching any topic in very deep.
@reeyasingh5309
Жыл бұрын
Yes, we need DSA series also please.
@prashantpandey5836
Жыл бұрын
Same brother
@sangameshbagalkot4753
Жыл бұрын
Yes Bro please start DSA session as it's required to crack product based interviews please 🙏🏻
@shorts_shots514
Жыл бұрын
yes plz namste DSA
@briandacallos4234
Жыл бұрын
Yes please
Thank you so much! Couldn’t find any other video that could explain promises better 🙏🏻
Your teaching skills are amazing and your passion for Javascript is contagious! Thank you for the videos :]
Thanks alot for teaching JavaScript in depth with so much passion. It has really helped alot and very grateful for your videos!
@akshaymarch7
Жыл бұрын
Thank you so much for supporting my channel, Arpit. This means a lot. ❤️
Please be consistent, love your content always.
I had a fear of this type of syntax in javascript after watching this video now i got this very easy ...thanks bhaiya for making it so simple .
there no boring at all while watching your videos continually and easy to learn thank you
promise object represents eventual completion of asynchronous operation Promises help us to solve problem of callback hell and inversion of control your content is awesome👍👍👍👍👍
a promise is an object representing the eventual completion or failure of an async task. Importance of promise: 1. to prevent callback hell 2. prevent inversion of control 3. generate trust
Promise is an object representing an eventual completion or failure of an asynchronous operation. YEAAHH I learned it
A promise is an object which represents the eventual completion or failure of an async operation. this heavy defination now fit in my mind.
1. A promise is an object that represents the eventual completion of an asynchronous operation. 2. Promises helps in handling asynchronous functions, they can be user over callbacks which are not trustworthy due to inversion of control. Promises also helps in making the code more readable and we can use promise chaining instead of getting into callback hell.
Thank you for sharing such valuable content!
@akshaymarch7
Жыл бұрын
Thank you so much for supporting my channel, Meghana. This means a lot. ❤️
A promise is the object that represent eventual completion of a function or some piece of code that will resolve itself asynchrounously, so that the code written after that promise object will execute only after executing the first piece of code.
Thanks a lot. For the first time I understood Promise in this clear way.
Promises are javascript object representing eventual completion or failure of asynchronous operation. Promises are used to overcome inversion of control and callback hell. promises are in three states pending ,fulfilled and rejected. promises are also known as future container for the data. Thanks brother for this video.....
Finallyyyyyyyyyyyyyyy..... THE WAIT IS OVERRR... CAN'T ARTICULATE MY EXCITEMENT INTO WORDS... JUST GRATEFUL... THANK YOU SO MUCH AKSHAY SAINI 🙏🙏🙏🤩🤩🤩🔥🔥
Thank you so much for what is to me the best explanation for Promises I have ever heard.
A primise is an object that represents an eventual completion or failure of an asyncronous operation 😎We use them to avoid callback hell, and inversion of control 😎 thank you, guru 🙏🏿
Thanks!
@akshaymarch7
Жыл бұрын
Thank you so much for supporting my channel, Anuj. This means a lot. ❤️
@Code_with_random
Жыл бұрын
@@akshaymarch7 good work bro😊
@princemishra5174
Жыл бұрын
@@akshaymarch7 Thank you so much bhaiya for teaching us in such a wonderful way. I am also fall in love with JavaScript because of you.
@swandev8916
Жыл бұрын
@@akshaymarch7 bhai decorator closure p bna do arrow p pls sab depth me , decorator jo lgta python me, bhai pls es6 major intrvw hisab bna do 30-30 min wle various topics
@odiobook
10 ай бұрын
Mane kafi try kiya par mujhe video trim karne ka koi solution online nahi mila JS se.. Jo mila h usmein ya video blank aati h ya phir trim nahi hoti... Please help me.
The way you break down the topic into digestible chunks and provide relevant examples really helps in understanding the material deeply. Thanks a ton boss.
Promises is an object that represent eventual completion of async operation Promises help US resolving issues like call back hell and inversion of control Thanks for best explanation
Thanks! And please continue this series
@akshaymarch7
Жыл бұрын
Thank you so much for supporting my channel, Ashutosh. This means a lot. ❤️
Thank you Akshay for such a great work..
@akshaymarch7
Жыл бұрын
Thank you so much for supporting my channel, Maruthi. This means a lot. ❤️
video is great, At the end funny touch of cramming "The Promise object represents the eventual completion of an asynchronous operation".
Best video on promises so far I have seen so many videos. Thank u brother
Please consistently upload videos🥹, so that we can able to sync with previous video reference and examples.
A promise is an object that represents the eventual completion of an async operation.
I appreciate & salute the passion you have for teaching...!! Loved your teaching. Learnt both JS and ReactJS from you. Thanks.
Thank You for such a beautiful explanation and just to mention loved the last 20s of the Video. Thank You
FIIIIINAAAAAAALLLLLLLLLY!
@robertobenedit
Жыл бұрын
I wait so long for you sharing your thought about this topic! LOVE FROM ARGENTINA!
You have taught me so many things brother thank you so much :)
@akshaymarch7
Жыл бұрын
Thank you so much for supporting my channel, Sailesh. This means a lot. ❤️
What a Great Explaination! hats Off To YOU ❤.. You made my day more meaningful.. Thank you sir😊😊😊
Totally in love with JavaScript
Promise : A promise is an object which represents the eventual completion or failure of an async operation. Advantages : - Prevents inversion of control & build confidence (Though the responsibility to complete/fail a task remain on the piece of code returning promise only). - Ensures the immutability of data. - Ensures that whatever needs to happen on completion of an async task gets only called once (no matter how many times a promise is resolved or rejected).
Tried to understand Promises for the last 1.5 years, but patiently waited for this video to understand it one day from Namaste JS and finally this beauty❤. All I understood: A promise is an object that represents the eventual completion of an asynchronous operation.❣ Promise states - Pending, Fulfilled, Rejected💕 Use .then() function on a promise object and get the data object once the promise is fulfilled. 💓 Promise Chaining💝
Assalam O Alaikum, You are my great and wonderful mentor in teaching JavaScript. You are such an amazing talented person to teach students from your experience. Huge respect and love from Pakistan 🇵🇰
The way you explained everything ❤️🔥
31:10 "we always return a promise from a promise when we are chaining them"
1 - Promesa es un objeto que representa la eventual complecion o falla en una operacion asincrona. 2 - Porque evita bugs, errores, dublicaciones y otras complicaciones al depender de una lista de callbacks de las cuales podemos no tener control, ademas produce el efecto de callback Hell, que hace que el codigo sea complejo de leer y mantener, ya que crece horizontalmente.
These concepts are crystal clear ..Thank you♥♥
Last wale rap ne to motivation X 100 kr diya
Promises helps us to keep control of our code with us, instead of passing control to another function. Promises ensures that our function is executed only once. Promise object is immutable, so we don't need to worry about it's immutability. It helps prevent callback hell, through promise chaining. It only has 3 states only: "Pending", "Fulfilled", "Rejected".
At 16:57, we can print the promise object using console.table() to see the state (pending) and result [at the time of logging]. Since expanding a object will always show the current value rather than at the time of printing. By using "console.table", it prints the values at the logging time and provide an option to view the current value beneath it.
@nitin4598
Жыл бұрын
helpful tip
i love the way u xplain! thanku so much
Your explanation is mind blowing bhaiya😯😯😯
Superb explanation. Thank u so much Akshay sir for these videos.
Promise- it is a object which represents the eventual states of asynchronous execution Benefits- Overcomes issue with callback function. We can Target data in all its states. Thanks bro for explaining in clear pattern
Your explanations are just amazing Akshay...Thanks a lot for this kind of explanation.
Promises: It is an object which represent the eventual completion or failure of asyn operation. Advantages: It saves data from api called and attach the callback api which makes code run only ones. It gives developers to more control over code. Thank you for making it easy to understand. 🙏
A promise is an Object , and that object represents the eventual Completion or Failure of an Asynchonous Operation. Thats It , Thank You Akshay Bhaiya