r/learnjavascript • u/Dark_Electric • Oct 18 '26
Promises
Understanding the concepts like functions, objects, arrays etc has been easy so far but promises are making my head hurt. Is it supposed to be this confusing? Did u guys struggle with it too when u were first learning it.
10
Upvotes
View all comments
1
u/Alternative_Can7374 Oct 18 '26
The easiest way to learn them is probably to consider them functions. You create two functions to your promise - the happy path (promise resolved - it's calling the function you provided in
then) - or the error path (promise rejected - it's calling the function you provided incatch). And it wont happen directly, but at the point your promise has resolved.Then you have some suger syntax on it with
awaitandcatch. Which I believe makes the concept of promises harder but the code easier.