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.

The style guide 11.1 says that you shouldn’t use for-of and instead should use forEach (which I completely agree with).

That said, the ESLint rule no-iterator doesn’t seem to enforce this, and the entry for no-restricted-syntax contains ForInStatement but not ForOfStatement.

Can we add ForOfStatement to no-restricted-syntax (or is the a better way of restricting for-of statements?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:122 (8 by maintainers)

github_iconTop GitHub Comments

285reactions
ljharbcommented, Nov 11, 2016

@dplusic in nice, simple ES6:

function foo(args) {
  return args.reduce((prev, arg) => prev.then(() => bar(arg), Promise.resolve());
}
157reactions
minexewcommented, Dec 5, 2016

@dplusic @ljharb I don’t understand. Where’s the advantage in making your code totally unreadable? Purity is nice, but not when it takes 30 minutes to decipher a simple function.

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 >
Remove array item using for...of loop - Stack Overflow
I'm trying to edit an array and remove elements that do not meet a certain condition. If I use ...
Read more >
disallow for-of statements (es/no-for-of-loops) | eslint ... - mysticatea
ESLint plugin about ECMAScript syntax.
Read more >
How to use the for…of Statement in JavaScript - Tabnine
The for…of statement is a very powerful for three reasons: It can loop through any iterable object – these include Strings, Arrays, array-like- ......
Read more >
JavaScript For Of - W3Schools
The JavaScript for of statement loops through the values of an iterable ... code block to be executed ... For/of was added to...
Read more >

github_iconTop Related Medium Post

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 Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found