question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

for...of loops don't work correctly

See original GitHub issue

https://stackblitz.com/edit/generator-loop

Checking the console in the example you can see no values are logged from the for (let value of create()) statement. Setting a breakpoint you can see in the compiled output of the for...of loop that length is undefined, skipping the loop.

image

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
dgreenspcommented, Mar 12, 2019

Ran into this wondering why for (const v of map.values()) { ... }didn’t iterate over anything.

Workaround is for (const v of Array.from(map.values())) { ... }.

0reactions
sulcocommented, Jan 25, 2021

Thanks everyone for reporting this issue and providing examples! Yeah, it was confusing…

Thankfully it should no longer be an issue 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Javascript 'for of' loop not properly resolving to the value
I get the error: "TypeError: i.getCenter is not a function. (In 'i.getCenter()', 'i.getCenter' is undefined)" I now understand that i.getCenter ...
Read more >
for...of - JavaScript | MDN - MDN Web Docs
The for...of statement executes a loop that operates on a sequence of values sourced from an iterable object. Iterable objects include ...
Read more >
For Loops, For...Of Loops and For...In Loops in JavaScript
The for statement is a type of loop that will use up to three optional expressions to implement the repeated execution of a...
Read more >
Loops: while and for - The Modern JavaScript Tutorial
Both loops alert the same values, or not? The task demonstrates how postfix/prefix forms can lead to different results when used in comparisons....
Read more >
Why this "for" loop doesn't work? | JavaScript - Reddit
There are two "right" ways to do a repeating delayed callback in JS: setTimeout with a callback that sets another timeout when it's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found