Repeats the given string `n` times.
repeat('*', 3)
// => '***'
repeat('abc', 2)
// => 'abcabc'
repeat('abc', 0)
// => ''
| Name | Type | Attribute | Description |
|---|---|---|---|
| string | The string to repeat. | ||
| n | The number of times to repeat the string. |
{
"comment": "/**\r\n * Repeats the given string `n` times.\r\n *\r\n * @since 3.0.0\r\n * @category String\r\n * @param {string} [string=''] The string to repeat.\r\n * @param {number} [n=1] The number of times to repeat the string.\r\n * @returns {string} Returns the repeated string.\r\n * @example\r\n *\r\n * repeat('*', 3)\r\n * // => '***'\r\n *\r\n * repeat('abc', 2)\r\n * // => 'abcabc'\r\n *\r\n * repeat('abc', 0)\r\n * // => ''\r\n */",
"meta": {
"range": [
399,
850
],
"filename": "repeat.js",
"lineno": 20,
"path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
"code": {
"id": "astnode100007721",
"name": "repeat",
"type": "FunctionDeclaration",
"paramnames": [
"string",
"n"
]
},
"vars": {
"result": "repeat~result",
"n": "repeat~n",
"string": "repeat~string"
}
},
"description": "Repeats the given string `n` times.",
"since": "3.0.0",
"tags": [
{
"originalTitle": "category",
"title": "category",
"text": "String",
"value": "String"
}
],
"params": [
{
"type": {
"names": [
"string"
]
},
"optional": true,
"defaultvalue": "''",
"description": "The string to repeat.",
"name": "string"
},
{
"type": {
"names": [
"number"
]
},
"optional": true,
"defaultvalue": 1,
"description": "The number of times to repeat the string.",
"name": "n"
}
],
"returns": [
{
"type": {
"names": [
"string"
]
},
"description": "Returns the repeated string."
}
],
"examples": [
"repeat('*', 3)\r// => '***'\r\rrepeat('abc', 2)\r// => 'abcabc'\r\rrepeat('abc', 0)\r// => ''"
],
"name": "repeat",
"longname": "repeat",
"kind": "function",
"scope": "global",
"___id": "T000002R000706",
"___s": true,
"filepath": "repeat.js"
}