TGViewer
JavaScript JavaScript @javascript · 31.1K subscribers
Post #2584 3.84K
Is there a difference between the previous code (red) and the new one (green) ?

Actually, there is 35second difference 😠

The previous code was, on every loop, creating a new object, always deallocating and reallocating memory, while the second example creates one object (a cache) and save each item into it.

Eduard Krivánek
  • 👍 13
  • 🔥 4
  • ❤ 3
More from @javascript
  1. Oct 2, 2026Post #3532
  2. Oct 2, 2026CHALLENGE const arr = [1, 2, 3]; const log = []; const result = arr.map((x, i) => { if (i…
  3. Oct 1, 2026Post #3530
  4. Oct 1, 2026CHALLENGE class Counter { #count = 0; static #instances = 0; constructor() { Counter.#inst…
  5. Sep 30, 2026Post #3528
  6. Sep 30, 2026CHALLENGE const message = 'a😀bc'; const codePoints = [...message]; const combined = { raw…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →