Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify characters iteration #4

Merged
merged 1 commit into from
May 3, 2021
Merged

Conversation

ebraminio
Copy link
Contributor

@ebraminio ebraminio commented May 3, 2021

Just to illustrate the issue better,

let text = '👌';
for (let i = 0; i < text.length; i += 1) { console.log(text[i]); } // FAIL: prints two incorrect characters
[...text].forEach(c => console.log(c)) // PASS: prints one character
for (const c of [...text]) { console.log(c); } // PASS
for (const c of text) { console.log(c); } // PASS

Also curious to know why 84ac195 was needed yet this won't revert that and just simplifies it.

Just to illustrate the issue better,

let text = '👌';
for (let i = 0; i < text.length; i += 1) { console.log(text[i]); } // FAIL: prints two incorrect characters
[...text].forEach(c => console.log(c)) // PASS: prints one character
for (const c of [...text]) { console.log(c); } // PASS
for (const c of text) { console.log(c); } // PASS
@coveralls
Copy link

Pull Request Test Coverage Report for Build 806572052

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 765171076: 0.0%
Covered Lines: 36
Relevant Lines: 36

💛 - Coveralls

@papandreou
Copy link
Owner

Ah, you're right that the spread isn't necessary, thanks 🎉

I added 84ac195 because forEach is "old school" now that we have for...of, not because there was a functional problem with it.

@papandreou papandreou merged commit ae451d1 into papandreou:master May 3, 2021
@papandreou
Copy link
Owner

Released in 1.2.1.

@ebraminio ebraminio deleted the patch-1 branch May 3, 2021 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants