Skip to content

Instantly share code, notes, and snippets.

@MikSDigital
Created July 26, 2016 11:36
Show Gist options
  • Save MikSDigital/29d5a0e0f1c2b3083afb0588b0b9610e to your computer and use it in GitHub Desktop.
Save MikSDigital/29d5a0e0f1c2b3083afb0588b0b9610e to your computer and use it in GitHub Desktop.
Printing the contents of an array
function logArrayElements(element, index, array) {
console.log('a[' + index + '] = ' + element);
}
// Notice that index 2 is skipped since there is no item at
// that position in the array.
[2, 5, , 9].forEach(logArrayElements);
// logs:
// a[0] = 2
// a[1] = 5
// a[3] = 9
@MikSDigital
Copy link
Author

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