Asynchronous JavaScript allows network requests and background timers to execute without freezing the browser UI thread.
1. Promises & async/await
async/await provides clean, synchronous-looking syntax for handling asynchronous operations.
⊞Code Example
// Fetching data asynchronously
async function fetchDeveloperData() {
try {
const response = await fetch("https://api.github.com/users/manojkmr2403");
if (!response.ok) {
throw new Error(`HTTP Error: ${response.status}`);
}
const data = await response.json();
console.log("GitHub User:", data.name, data.public_repos);
return data;
} catch (err) {
console.error("Fetch failed:", err);
}
}
fetchDeveloperData();
