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.

New transform: for loops to `for of`

See original GitHub issue

Convert this

for (var i = 0; i < fruits.length; i++) {
   console.log(fruits[i]);
}

to this

for (let fruit of fruits) {
  console.log(fruit)
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
nenecommented, Aug 19, 2016

This is now released as v2.2.0

1reaction
nenecommented, Aug 18, 2016

@siddharthkp I think that’s my general opinion as well. One really shouldn’t use Lebab blindly - the changes need some human review.

Then again, Lebab should not do changes that might break stuff. Ideally when reviewing the transformed code you would not need to fix any actual bugs, but more like manually transform the cases that Lebab didn’t handle or adjust the code style when Lebab didn’t format the code to the best of your preferences.

In that regard some transforms are very safe, like obj-shorthand. Some can currently fail with rare edge-cases, like arrow, while the goal is to fix these bugs. But some transforms don’t guarantee strictly equivalent code - like the default arguments aren’t really equivalent to a = a || 3 - I’ve classified those to the “Unsafe” category. The latter ones can’t really be implemented in a way that would make the transform perfectly safe, but they work fine for most of the code.

Read more comments on GitHub >

github_iconTop Results From Across the Web

17. The for-of loop - Exploring JS
for-of is a new loop in ES6 that replaces both for-in and forEach() and supports the new iteration protocol. Use it to loop...
Read more >
Refactor to convert a for loop to a foreach statement
Learn how to use the Quick Actions and Refactorings menu to convert between a for loop and a foreach statement.
Read more >
How to transform a column using a for loop - Stack Overflow
I am trying to transform Amazon product names into specific categories and replace the original values in my data frame. How do I...
Read more >
How to convert this foreach to a for loop - Unity Forum
transform ; // you are creating a new Transform object called child, but setting it as the current gameobject. spawnPoints.Add(child.position); }.
Read more >
Parallelize a For-Loop by Rewriting it as an Lapply Call
Below are a few walk-through examples on how to transform a for-loop into an lapply call.
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