Skip to content

Instantly share code, notes, and snippets.

@youpy
Created March 17, 2009 17:14
Show Gist options
  • Save youpy/80662 to your computer and use it in GitHub Desktop.
Save youpy/80662 to your computer and use it in GitHub Desktop.
Array.prototype.join2 = function(f) {
if(typeof f != 'function') {
return this.join(f);
}
return this.reduce(function(memo, item) {
return memo + f() + item;
});
};
["a", "b", "c"].join2(function() {
var separator = ",.!#$%&";
return separator[Math.floor(Math.random() * separator.length)];
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment