JavaScript String repeat()
Example
Make a new string by copying a string twice:
var str = "Hello world!";
str.repeat(2);
Try it Yourself »
Definition and Usage
The repeat() method returns a new string with a specified number of copies of
the string it was called on.
Browser Support
The numbers in the table specify the first browser version that fully supports the method.
| Chrome 41 | Edge 12 | Firefox 24 | Safari 9 | Opera 28 |
| Mar 2015 | Jul 2015 | Sep 2013 | Oct 2015 | Mar 2015 |
The repeat() method is not supported in IE 11 (and earlier versions).
Syntax
string.repeat(count)
Parameter Values
| Parameter | Description |
|---|---|
| count | Required. The number of times the original string value should be repeated in the new string |
Technical Details
| Return Value: | A String, a new string containing copies of the original string |
|---|---|
| JavaScript Version: | ECMAScript 6 |

