YouTube2Text

You can't break a forEach loop in JavaScript.#javascript #webdevelopment #programming #frontend — Transcript

by Scale in 60 sec · 176 words · 24 segments · language en · Watch on YouTube

Full transcript

  1. 0:004 years into JavaScript, I found a loop
  2. 0:03I could never stop. Did you know this?
  3. 0:06You write for each and when you hit
  4. 0:08three, you try to break.
  5. 0:09JavaScript throws a syntax error.
  6. 0:14So, you try return. It doesn't stop the
  7. 0:16loop. It only skips that one call and
  8. 0:18four and five still run.
  9. 0:22For years, I had no clue why. I just
  10. 0:24kept writing the loop and hoping.
  11. 0:28Then it clicked. It isn't a loop at all.
  12. 0:32The reason
  13. 0:34for each takes a callback and a callback
  14. 0:36is just a function. Return leaves that
  15. 0:38function, never the loop around it.
  16. 0:41Need to stop early? Use a for of loop
  17. 0:44where break works or some or every which
  18. 0:46stop as soon as the answer is known.
  19. 0:51MDN says the only way to stop for each
  20. 0:53is to throw an exception. If you need to
  21. 0:55stop, for each is the wrong tool.
  22. 0:58It took me 4 years to learn this. How
  23. 1:00long did it take you? Tell me in the
  24. 1:02comments and follow for more JavaScript.

About this transcript

This page contains the full transcript of You can't break a forEach loop in JavaScript.#javascript #webdevelopment #programming #frontend by Scale in 60 sec, generated from the public captions YouTube serves with the video. The transcript has 176 words across 24 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.