Web Development - HTML, CSS & JavaScript
47.4K subscribers
1.45K photos
3 videos
32 files
273 links
Learn to code and become a Web Developer with HTML, CSS, JavaScript , Reactjs, Wordpress, PHP, Mern & Nodejs knowledge

Managed by: @love_data
Download Telegram
Here is a great JavaScript interview question!

What the heck is a Promise doing under the hood?

In JavaScript, things usually happen one after the other. It's like a checklist each item gets done before moving to the next.

When a function returns a Promise, it's like making a promise to do something, like fetch data from the internet. But JavaScript doesn't wait around for the data to come back. Instead, it moves on to the next task.

Now, here's where things get interesting. While JavaScript is busy doing other stuff, like running more code, the Promise is off fetching data in the background.

Once the data is fetched, the Promise is fulfilled, and it has some information to share. But JavaScript needs to know when it's time to handle that information. That's where the onFulfilled part of the Promise comes in.

When the Promise is fulfilled, JavaScript takes the onFulfilled code and puts it in a special queue, ready to be run.

Now, async/await enters the scene. When we mark a function as async, we're telling JavaScript, "Hey, this function might take some time to finish, so don't wait up for it."

And when we use the await keyword inside an async function, it's like saying, "Hold on a sec, JavaScript. I need to wait for something important before moving on."

So, when JavaScript encounters an await keyword, it pauses and lets the async function do its thing. If that thing happens to be a Promise, JavaScript knows it can move on to other tasks while waiting for the Promise to resolve.

Once the Promise is resolved, JavaScript picks up where it left off and continues running the code.

Promises and async/await allow JavaScript to handle asynchronous tasks while keeping things organized and in order. Promises handle the background tasks, while async/await makes it easier to work with them in our code, ensuring everything happens in the right sequence.

Web Development Best Resources: https://topmate.io/coding/930165

ENJOY LEARNING 👍👍
⌨️ JavaScript Array methods
𝟏. 𝐉𝐚𝐯𝐚𝐒𝐜𝐫𝐢𝐩𝐭+𝐑𝐞𝐚𝐜𝐭
Front-end web development
𝟐. 𝐉𝐚𝐯𝐚𝐒𝐜𝐫𝐢𝐩𝐭+𝐀𝐧𝐠𝐮𝐥𝐚𝐫
Front-end web development
𝟑. 𝐉𝐚𝐯𝐚𝐒𝐜𝐫𝐢𝐩𝐭+𝐕𝐮𝐞.𝐣𝐬
Front-end web development
𝟒. 𝐇𝐓𝐌𝐋+𝐂𝐒𝐒
Basic web structure and styling
𝟓. 𝐉𝐚𝐯𝐚𝐒𝐜𝐫𝐢𝐩𝐭+𝐍𝐨𝐝𝐞.𝐣𝐬:
Back-end development
𝟔. 𝐏𝐲𝐭𝐡𝐨𝐧+𝐃𝐣𝐚𝐧𝐠𝐨
Web development (back-end)
𝟕. 𝐏𝐲𝐭𝐡𝐨𝐧+𝐅𝐥𝐚𝐬𝐤
Web development (back-end)
𝟖. 𝐉𝐚𝐯𝐚+𝐒𝐩𝐫𝐢𝐧𝐠 𝐁𝐨𝐨𝐭
Enterprise-level back-end development
In JavaScript, a Proxy is an object that allows you to intercept and redefine fundamental operations for another object. This enables custom behavior for things like property access, function calls, and more. Proxies are part of ECMAScript 6 (ES6) and provide a way to control how an object interacts with the rest of your code.