Skip to content

Instantly share code, notes, and snippets.

@westc
Created September 2, 2018 02:05
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 westc/247c495830d39d778237d1d9192a15cb to your computer and use it in GitHub Desktop.
Save westc/247c495830d39d778237d1d9192a15cb to your computer and use it in GitHub Desktop.
YourJS candidate function: array()
// Creates an array with the specified length and filling it with the specified value.
function array(length, opt_filler, opt_callFiller) {
opt_callFiller = !!opt_callFiller && 'function' === typeof opt_filler;
for (var result = Array(length), i = 0; i < length; i++) {
result[i] = opt_callFiller ? opt_filler(result[i], i, result) : opt_filler;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment