Skip to content

Instantly share code, notes, and snippets.

@deathshadow60
Last active September 28, 2020 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deathshadow60/72932df1003de520ab309701395f431c to your computer and use it in GitHub Desktop.
Save deathshadow60/72932df1003de520ab309701395f431c to your computer and use it in GitHub Desktop.
For/of and [] assignment, way better than foreach and faster than filter
var
grades = [33, 90, 78, 94, 56, 88, 97],
passed = [];
for (var grade of grades) if (grade >= 70) passed[passed.length] = grade;
console.log(passed); // should output [ 90, 78, 94, 88, 97 ]
@deathshadow60
Copy link
Author

I'll take for/of over foreach all day every day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment