Skip to content

Instantly share code, notes, and snippets.

@davodey
Last active January 24, 2017 22:04
Show Gist options
  • Save davodey/931ce32fa2bd9aa5489e16ea58f1e6e3 to your computer and use it in GitHub Desktop.
Save davodey/931ce32fa2bd9aa5489e16ea58f1e6e3 to your computer and use it in GitHub Desktop.
Example using the ES6 forEach helper.
var colors = [ 'red', 'blue', 'green'];
// syntax we want to move away from
for (var i = 0; i < colors.length; i++) {
console.log(colors[i]);
}
// syntax we want to use
colors.forEach(function(color){
console.log(color);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment