Easy Tutorial
❮ Prop Style Right Jsref Tostring Number ❯

JavaScript String repeat() Method

JavaScript String Object

Example

Duplicate the string "tutorialpro" twice:

n Output result:


Definition and Usage

The repeat() method duplicates the string a 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 duplicate the string.

Return Value

Type Description
String Returns a string that is duplicated the specified number of times and concatenated together.

Technical Details

| JavaScript Version: | ECMAScript 6 | | --- | --- |


JavaScript String Object

❮ Prop Style Right Jsref Tostring Number ❯