Back

Shubham

Fearless • 1m

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

Shubham

Fearless • 1m

Day 11/21 – JavaScript API Calls 🌐 Today I explored how to fetch data from APIs in JavaScript using async/await. Copy code Javascript async function getUsers() { try { let response = await fetch("https://jsonplaceholder.typicode.com/users");

See More
Reply
2

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 • 1m

🚀 Day 2 of 21 – JavaScript Learning Journey Topic: Operations & Conditional Statements 🔹 Operations in JavaScript Arithmetic: + - * / % Assignment: = += -= Comparison: == === != > < >= <= Logical: && || ! 🔹 Conditional Statements // if sta

See More
1 Reply
1
16

Shubham

Fearless • 1m

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

Shubham

Fearless • 1m

Day 09/21 – JavaScript Classes & Objects Today I explored Classes & Objects in JavaScript – the building blocks of Object-Oriented Programming (OOP). 🚀 🔹 Objects = collections of data & methods 🔹 Classes = blueprints to create objects Example:

See More
Reply
8

Shubham

Fearless • 1m

🚀 Day 3/21 – My JavaScript Learning Journey Today I explored two core concepts: Loops & Strings. 🔹 Loops in JavaScript for → classic loop with index. while → runs until a condition is true. do...while → executes at least once. for...of → best

See More
Reply
2

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