Promises in javascript | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Promises in javascript

I could not understand promises in sololearn. can anyone give me suggestions to learn promises?

8th May 2020, 9:10 AM
Shadman Sakib
Shadman Sakib - avatar
20 Answers
+ 7
My fresh video tutorial about Promise https://youtu.be/s6Nd4x_RJPw
9th May 2020, 8:00 AM
Gordon
Gordon - avatar
+ 7
Shadman Sakib Are you already familiar with the conceptual meanings of synchronous and asynchronous processing? If not, then you'll want to learn more about these concepts and the differences between sync vs async in order to better understand how promises play a role in supporting various async patterns.
9th May 2020, 8:37 AM
David Carroll
David Carroll - avatar
+ 5
Promise is a new feature of ES6. It is most probably used to fetch data from an api. Or simple it is used to get some data which takes some time to load. When you try to load data from an api, it will generally take some time, right? And hence if you try to access the data before it is loaded, you will get errors. Therefore, the solution is to use promise. Check out this code for an example :)) https://code.sololearn.com/WApBRrc6CHB8/?ref=app
8th May 2020, 9:14 AM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
+ 5
Crash While the written expression of "facepalm" may be lost in translation, I bet you'll instantly know the emoji version of this meaning... 🤦‍♂️ If that's still unfamiliar, this link should help: 😉👌 https://en.m.wikipedia.org/wiki/Facepalm
9th May 2020, 7:46 PM
David Carroll
David Carroll - avatar
+ 5
After learning Promise, learn #2 async / await https://youtu.be/2RzzTapgTvM It saves us from having to use a lot of callback functions. After that, learn the applications of asynchronous programming : #3 Using fetch() to send HTTP GET Request to fetch JSON data from API - with randomuser as demonstration. https://youtu.be/is0QYV0oHx0 #4 Web Scraping with fetch() and cors-anywhere.herokuapp and DOMParser, with logo of my website as example. https://youtu.be/pZbrP9ZDf6s All videos are just freshly recorded, here is a playlist of my JS Asynchronous series : https://www.youtube.com/playlist?list=PLkqwj9vc20pX36wThr2A6DZx4MVcJvnhe
10th May 2020, 6:29 AM
Gordon
Gordon - avatar
+ 3
Shadman Sakib To understand Promise, firstly you have to understand asynchronous function as what David Carroll highlighted. Secondly, you need to understand the arguments of new Promise(okCallback, errorCallback), which are the callback functions, we would use okCallback(data) when we return the working result, data of a function (normally async function). And we would use errorCallback(error) to return error, when the async function encounters error. Next question is "How does the function get the async parameter of okCallback or errorCallback function?" We chain the return of new Promise object with then and catch functions (.then( d=> console.log(d)).catch( err => console.log(err))). Eventually we could expect the parameter of okCallback would be parameter input of .then callback. And errorCallback parameter would be parameter input of .catch callback. Study this simple example https://code.sololearn.com/W0947gjP8TOf/?ref=app
9th May 2020, 10:36 AM
Calviղ
Calviղ - avatar
+ 2
open async function it is a mini series : https://code.sololearn.com/WKKkpq0efxai/?ref=app
8th May 2020, 10:16 AM
Gordon
Gordon - avatar
+ 2
https://javascript.info/promise-basics
8th May 2020, 10:27 AM
ODLNT
ODLNT - avatar
9th May 2020, 3:15 PM
narayanaprasad
narayanaprasad - avatar
+ 2
narayanaprasad I'm usually disappointed in the poor quality of many articles published these days. That said, I was quite impressed with the quality of the web.dev article. I typically avoid wasting my time reading content from geeksforgeeks.org. There's only so much disappointment and face-palming one can take. 😉 In any case, thanks for sharing the web.dev article.
9th May 2020, 6:20 PM
David Carroll
David Carroll - avatar
+ 1
I can't understand sololearn promises
8th May 2020, 9:53 AM
Shadman Sakib
Shadman Sakib - avatar
+ 1
thanks all ☺
8th May 2020, 10:41 AM
Shadman Sakib
Shadman Sakib - avatar
0
give me other sources than sololearn
8th May 2020, 9:52 AM
Shadman Sakib
Shadman Sakib - avatar
0
ok
9th May 2020, 8:13 AM
Shadman Sakib
Shadman Sakib - avatar
0
thanks
9th May 2020, 12:50 PM
Shadman Sakib
Shadman Sakib - avatar
0
Hi David Carroll I think I have a language problem. What does "face-palming" mean? Is it when you clap your hands onto your face like this: 🙈?
9th May 2020, 6:53 PM
Crash
Crash - avatar
0
Thank's David Carroll , that's what I meant when I posted my 'monkey'... I think the German equivalent would be: 'sich an den Kopf fassen'. =>'touch your head'.
9th May 2020, 8:01 PM
Crash
Crash - avatar
0
nice language battle guys 😅
9th May 2020, 9:45 PM
Shadman Sakib
Shadman Sakib - avatar
0
@Gordon 😅 difficult things
10th May 2020, 3:48 PM
Shadman Sakib
Shadman Sakib - avatar