Repeat a string
suggest changeUse String.prototype.repeat():
'abc'.repeat(3); // 'abcabcabc'
'abc'.repeat(0); // ''
'abc'.repeat(-1); // RangeError
The count is converted with ToInteger, so a fractional count is truncated toward zero. Negative counts and Infinity throw RangeError. A very large count must allocate the whole result.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents