- Modern JavaScript Web Development Cookbook
- Federico Kereki
- 52字
- 2021-07-02 14:49:52
Repeating strings
Let's finish with several new string-related functions. Most are pretty simple to understand, so the explanations will mostly be brief. For a complete list of all available string functions, both old and new, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String.
You can iterate any string using the .repeat(...) method:
"Hello!".repeat(3); // Hello!Hello!Hello!