What are the differences between Thread and Promise

Asked

Viewed 156 times

1

I am more of the desktop world, but I’m wanting to know more about WEB. And I wonder if there is a difference between javascript and C thread#.

  • 1

    There is a difference, yes, they are two completely different things.

1 answer

0


Thread and Promise are completely different things.

The engine that runs js in the browser is single-thread, as javascript is event-driven we usually don’t work directly with the thread but with the eventloop.

Promise is a feature that has come to end the excessive callback call, where it will perform a processing asynchronously. According to the documentation: A Promise (from "promise") represents a value that may be available now, in the future or never.

A Promise can assume 4 states. ( pending, held, rejected, settled)

For full information, please visit the documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise

Browser other questions tagged

You are not signed in. Login or sign up in order to post.