Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Asynchronous JavaScript – Callbac | JavaScript Course lesson | BraveProgrammer
  1. Courses
  2. /
  3. JavaScript Course

Lesson 14 of 55

·javascript

Asynchronous JavaScript – Callbacks, Promises & async/await

13 mins

Course progress25%

What you'll learn

Keep these ideas in mind as you work through the lesson.

3 points
  • `async` functions always return a **Promise**.
  • `await` can only be used inside an `async` function.
  • Errors thrown inside an `async` function are caught by `try…catch` or by `.catch()` on the returned promise.

Callbacks – traditional way, leads to “callback hell”.

setTimeout(() => {
  console.log('first');
  setTimeout(() => console.log('second'), 500);
}, 500);

Promises – represent a future value.

fetch('https://api.example.com/data')
  .then(r => r.json())
  .then(data => console.log(data))
  .catch(err => console.error(err));

async/await – syntactic sugar over promises.

async function load(){
  try {
    const r = await fetch('/data.json');
    const d = await r.json();
    console.log(d);
  } catch(e){ console.error(e); }
}
load();
Make it stickPractice what you've learned1 quiz · 7 practical tests · Optional activities from JavaScript CourseBrowse activities
Previous lessonModern JavaScript – ES6 ModulesContinue to lesson 15Fetching Data – `fetch` API & JSONBack to JavaScript Course curriculum