> For the complete documentation index, see [llms.txt](https://lodash.shujuwajue.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lodash.shujuwajue.com/string/repeat.md).

# \_.repeat（重复给定字符串）

**语法：**

```javascript
_.repeat([string=''], [n=1])
```

**源代码链接：**[source](https://github.com/lodash/lodash/blob/4.17.10/lodash.js#L14507)

**npm包链接：**[npm package](https://www.npmjs.com/package/lodash.repeat)

**描述：**

重复 N 次给定字符串。

**开始版本：**&#x33;.0.0

**参数：**

* `[string=''] (string)`: 要重复的字符串。
* `[n=1] (number)`: 重复的次数。

**返回值：**

* `(string)`: 返回重复的字符串。

**例子：**

```javascript
_.repeat('*', 3);
// => '***'

_.repeat('abc', 2);
// => 'abcabc'

_.repeat('abc', 0);
// => ''
```
