Repeat a string

suggest change

Use 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.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents