Standard built-ins
String.prototype.repeat()
Concatenates copies; zero yields empty text. Negative or infinite converted counts throw RangeError. Excessive resulting length can also fail.
Formal Syntax & Structure
javascript syntaxjavascript
text.repeat(count)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| count | Number | Number of copies after integer conversion. |
Return Value
String
Concatenated copies.
Working Example
Example Snippetjavascript
console.log("ab".repeat(2));