What is async/await in JavaScript?
Answer
async/await (ES8) is syntactic sugar over Promises that allows writing asynchronous code in a synchronous-looking style. Mark a function with async — it automatically returns a Promise. Use await inside an async function to pause execution until the awaited Promise settles, then resume with the resolved value. Example: async function fetchUser(id) { try { const response = await fetch(`/users/\${id}`); const data = await response.json(); return data; } catch(err) { console.error(err); } }. Error handling uses try/catch instead of .catch(). Run Promises concurrently: const [user, posts] = await Promise.all([fetchUser(), fetchPosts()]). Await can only be used inside async functions (top-level await is supported in ES modules). async/await makes async code significantly more readable and easier to debug.