New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
array function: repeat val x times #868
Labels
Comments
+1 for an array repeat function. I wouldn't modify |
Instead of another method we could just mod var zeros = _.times(10, function() { return 0; });
// => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] |
+1 @jdalton. |
Sounds good to me -- go for it. |
jashkenas
added a commit
that referenced
this issue
Nov 26, 2012
fixes #868: _.times collects return values
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
suggested impl:
or alternatively, modify _.range function so that:
Here is the use case:
But, what if i want to initialize every value in the key/value pairs to the same value?
This could be another option but doesn't work:
This would work if _repeat existed:
The text was updated successfully, but these errors were encountered: