Skip to main content
Version: 3.27.2

String.prototype.repeat()

The repeat() method constructs and returns a new string which contains the specified number of copies of the string on which it was called, concatenated together.

Syntax

repeat(count)

Parameters

  • count
    • : An integer between 0 and +Infinity, indicating the number of times to repeat the string.

Return value

A new string containing the specified number of copies of the given string.

Exceptions

  • Throws a RangeError if repeat count is negative.
  • Throws a RangeError if repeat count is infinity or overflows maximum string size.