JavaScript String repeat()Method
Example
Copy the string "Example" twice:
var str = "Example";
str.repeat(2);
nOutput:
ExampleExample
Try it »
Definition and Usage
The repeat() method copies a string the specified number of times.
Browser Support
The numbers in the table specify the first browser version that fully supports the method.
| Method | |||||
|---|---|---|---|---|---|
| repeat() | 41 | 12.0 | 24.0 | 9 | 28 |
Syntax
string.repeat(count)
Parameter Values
| Parameter | Description |
|---|---|
| count | Required. Sets the number of times to copy. |
Return Value
| Type | Description |
|---|---|
| String | Returns a string that is the specified number of copies of the original string concatenated together. |
Technical Details
| JavaScript Version: | ECMAScript 6 |
|---|
Other Extensions
JavaScript String Object