JavaScript Glossary: String repeat()

Written by - - Aggregated on Saturday February 9, 2019


The String repeat() method is a very fun one. You can take any string and repeat over it so that it displays multiple times.

"hello ".repeat(5);
// output: hello hello hello hello hello

It can also work with emojis!


// output: ?✨??✨??✨??✨??✨??✨??✨??✨??✨??✨?

This can be useful as filler text or for annoying your friends.



1 parameter

count (integer)

The number of times you want to repeat over the string.

Returns a new string

Repeat() does not affect the original string. It creates a new one and returns that.

« JavaScript Glossary: String replace() -

Symfony blog - A Week of Symfony #632 (4-10 February … »