Created
April 7, 2018 23:27
-
-
Save idmontie/62c0f1c05ec690ab753024875caf3a92 to your computer and use it in GitHub Desktop.
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
function fillArray(length, value = 0) { | |
return Array.from({ length }, () => value); | |
} | |
console.log(fillArray(10, 0)); // [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] | |
console.log(fillArray(2, null)); // [null, null] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment