ES6 - New String Method repeat()


Advertisements

This function repeats the specified string for a specified number of times.

Syntax

str.repeat(count)

Parameters

  • Count − number of times the string should be repeated.

Return Value

Returns a new string.

Example

var myBook = new String("Perl"); 
console.log(myBook.repeat(2)); 

Output

PerlPerl 
es6_new_string_methods.htm
Advertisements