Back

Shubham

Fearlessย โ€ขย 17h

Day 10/21 โ€“ JavaScript: Callback, Promise & Async/Await Today I learned how JavaScript handles asynchronous tasks like API calls, file loading, or timers. โšก ๐Ÿ”น Callback โ€“ a function passed into another function function fetchData(cb) { setTimeout(() => cb("Data received!"), 1000); } fetchData(msg => console.log(msg)); ๐Ÿ”น Promise โ€“ cleaner way to handle async let data = new Promise((res) => { setTimeout(() => res("Promise resolved!"), 1000); }); data.then(msg => console.log(msg)); ๐Ÿ”น Async/Await โ€“ modern & readable syntax async function getData() { let result = await data; console.log(result); } getData(); ๐Ÿ‘‰ Callback = nesting ๐Ÿ‘‰ Promise = chaining ๐Ÿ‘‰ Async/Await = clean & readable This is the heart of modern JS development ๐Ÿš€ #21DayJavaScript #JavaScript #WebDevelopment #CodingJourney #LearnInPublic

Reply
1

More like this

Recommendations from Medial

Sagar gupta

Full-time Freelancer...ย โ€ขย 1y

Most Javascript Questions Asked in Interview | PART 2 1. What is difference between a for loop and for Each loop Ans: A for loop is traditional loop that uses a counter variable to iterate over an array. ForEach loop is a method that iterate over a

See More
Reply
3
10

Inayat Hasan

Software engineerย โ€ขย 1y

[This post has been deleted by the creator]

Reply
1
3

Shubham

Fearlessย โ€ขย 6d

Day 05/21 โ€“ JavaScript Functions & Methods Today I explored one of the most powerful concepts in JavaScript: Functions & Methods. ๐Ÿš€ ๐Ÿ”น Functions are blocks of code designed to perform a specific task. They help in reusability and make code cleaner

See More
Reply
1

Download the medial app to read full posts, comements and news.