AITeky Learn

AiTeky Original Interactive Learning & Practice Intermediate

JavaScript: closures in loops, waiting in parallel and the slow dashboard

See why callbacks created in a loop can all report the last value, how waiting for requests one after another differs from waiting for them together, and speed up a dashboard that makes eight requests in a row.

JavaScript runs almost everywhere a user clicks, and two ideas cause a large share of its surprises: closures (a function remembers the variables around it, not a snapshot of their values) and asynchronous waiting (a program can start several slow jobs and wait for them together, or one at a time).

This course models both with small Python programs you can run in your browser. Python stands in for JavaScript: the code is not JavaScript, but the behaviour and the timing sums it shows are the same. Check the JavaScript documentation for exact syntax, such as let in loops and Promise.all. All numbers are made up.

  • Learn lessons explain one idea at a time and let you run it.
  • Industry ready lessons decide and justify, and end with interview questions.

No JavaScript experience is assumed. Basic Python helps.

Locked. Sign up free

Learn

Understand each idea with everyday examples. No coding background needed.

  1. 01 25 min Free sample 🔒 AiTeky Pass Callbacks that all say the last value See why functions made in a loop can all see the loop variable's final value, and fix it by giving each function its own copy.
  2. 02 25 min 🔒 AiTeky Pass Waiting one by one or together Work out the total waiting time when slow jobs run one after another, all together, or in groups, and see why independent requests should not wait in a line.

Industry ready

Real problems from real jobs, and the questions interviewers ask about them.

  1. 03 30 min 🔒 AiTeky Pass On the job: the dashboard that waited in line A dashboard makes eight requests in a row and takes nearly two seconds. Model the waiting, compare four fixes by effort and risk, choose, and write the note.

We use essential cookies to run the site. With your permission we also set one anonymous ID to count unique visitors, and analytics cookies to see which pages help learners. Cookie notice

Join AiTeky Learn. It's free.

Create a free account to track your progress, save items for later and get study suggestions.

Sign up free Log in