New transform: for loops to `for of`
See original GitHub issueConvert 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:
- Created 7 years ago
- Comments:6
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is now released as v2.2.0
@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, likearrow
, 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 toa = 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.