Skip to content

Instantly share code, notes, and snippets.

@shaunwallace
Created November 19, 2014 14:18
Show Gist options
  • Save shaunwallace/02359278e06f80e0292e to your computer and use it in GitHub Desktop.
Save shaunwallace/02359278e06f80e0292e to your computer and use it in GitHub Desktop.
Array.prototype.map()
// iterating through a collection of elements returned by querySelectorAll
var elems = document.querySelectorAll('select option:checked');
var values = [].map.call(elems, function(obj) {
return obj.value;
});
// reverse a string
var str = '12345';
[].map.call(str, function(x) {
return x;
}).reverse().join('');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment