r/learnjavascript • • 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

25 comments sorted by

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 in catch). And it wont happen directly, but at the point your promise has resolved.

Then you have some suger syntax on it with await and catch. Which I believe makes the concept of promises harder but the code easier.