DEV Community 👩‍💻👨‍💻

asiddharth94
asiddharth94

Posted on

repeat() - JavaScript

The repeat() is called on a string which takes one argument (number of times the string needs to be repeated) and returns a new string , containing the repetitions of the string on which it was called (argument times), concatenated together.

Note - The argument passed must be non-negative and the new string formed must not overflow the maximum string size.

'#'.repeat(3) returns '###'

Top comments (1)

This post blew up on DEV in 2020:

js visualized

🚀⚙️ JavaScript Visualized: the JavaScript Engine

As JavaScript devs, we usually don't have to deal with compilers ourselves. However, it's definitely good to know the basics of the JavaScript engine and see how it handles our human-friendly JS code, and turns it into something machines understand! 🥳

Happy coding!