Is there really nothing that can automatically convert oldschool “for” loops into array helper methods? (JS)

Been wondering this for a while, and it must not exist for a reason.

Am spending today refactoring (hundreds of lines of) code that uses `for` loops, am swapping to use the much nicer helper methods, e.g. `.forEach` and `.map`, was just curious whether someone…somewhere…surely…has made some sort of automatic converter. Wouldn't that be relatively easy? Is it more complex than I am imagining, to automate this?

It surprises me that, say, something like IntelliJ which understands your code enough to suggest ways to autofill or make 'better', wouldn't have some sort of prompt that says "Hey – can see you're iterating through an array with a `for` loop here, would you rather use `forEach`?". Someone tell me why this is me being dumb, because it must not exist for a reason. Or perhaps it does!

submitted by /u/panda182
[link] [comments]

from Software Development – methodologies, techniques, and tools. Covering Agile, RUP, Waterfall + more! https://ift.tt/2TtJdL2

Leave a comment

Design a site like this with WordPress.com
Get started
search previous next tag category expand menu location phone mail time cart zoom edit close