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

Can we replace all instances of forEach in JS? #31

VincentTam opened this issue Aug 12, 2019 · 2 comments


Copy link

commented Aug 12, 2019

In assets/js/index.js, there're several instances of forEach, which is 95% slower than for. I wonder if they can be replaced by for.


This comment has been minimized.

Copy link

commented Aug 12, 2019

The reason I use forEach is because it's a cleaner functional approach. Please see the comments section of the link you cited. See the comments by KirbyWallace, the-simian, stdio, syifaazzahra & Konstrukt.

I think map() would be a better replacement

@VincentTam VincentTam added the question label Aug 12, 2019


This comment has been minimized.

Copy link
Collaborator Author

commented Aug 12, 2019

Thanks for pointing the bolded comments. I'm working on your JS for the project. Thanks to forEach, the syntax can be more beautiful, even though the upcoming modified JS would be a sphaghetti of JS + Hugo code.

  function clearForm() {
    // empty all text & hidden fields
    elems('.form_input').forEach((form_input) => {form_input.value = ''});

@VincentTam VincentTam closed this Aug 12, 2019

@VincentTam VincentTam added the wontfix label Aug 12, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.