"string".repeat(0)

Brendan Eich brendan at mozilla.org
Thu Nov 22 21:49:13 PST 2012


David Bruant wrote:
> Le 22/11/2012 21:44, Allen Wirfs-Brock a écrit :
>> See https://bugs.ecmascript.org/show_bug.cgi?id=922
>>
>> What do people think?  Should a repeat count of 0 be accepted and 
>> produce an empty string?
> I would expect so.

Definitely. 0 is the basis case, not 1. See Ruby (as noted in the bug), 
also Perl, PHP, and many, many other languages:

http://rosettacode.org/wiki/Repeat_a_string

/be


More information about the es-discuss mailing list