Created
September 2, 2018 02:05
-
-
Save westc/247c495830d39d778237d1d9192a15cb to your computer and use it in GitHub Desktop.
YourJS candidate function: array()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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
https://www.yourjs.com/console?gist=247c495830d39d778237d1d9192a15cb&file=array.js