English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

JavaScript String repeat() Method

 JavaScript String Object

repeat()The method returns a new string that contains the specified number of copies of the called string concatenated together.

Syntax:

string.repeat(count)
var str = 'oldtoolbag.com';
str.repeat(4);
Test to see‹/›

Browser Compatibility

The numbers in the table specify the first browser version that fully supports the repeat() method:

Method
repeat()4124Yes912

Parameter Value

ParameterDescription
countThe number of times the original string value should be repeated in the new string

Technical Details

Return Value:A new string containing the specified number of copies of the given string
Exception Cases:RangeError: The repetition count must be a non-negative number, and the repetition count must be less than infinity and cannot overflow the maximum string size
JavaScript Version:ECMAScript 6

 JavaScript String Object