Checks if `string` ends with the given target string.
endsWith('abc', 'c')
// => true
endsWith('abc', 'b')
// => false
endsWith('abc', 'b', 2)
// => true
| Name | Type | Attribute | Description |
|---|---|---|---|
| string | The string to inspect. | ||
| target | The string to search for. | ||
| position | The position to search up to. |
{
"comment": "/**\r\n * Checks if `string` ends with the given target string.\r\n *\r\n * @since 3.0.0\r\n * @category String\r\n * @param {string} [string=''] The string to inspect.\r\n * @param {string} [target] The string to search for.\r\n * @param {number} [position=string.length] The position to search up to.\r\n * @returns {boolean} Returns `true` if `string` ends with `target`,\r\n * else `false`.\r\n * @see includes, startsWith\r\n * @example\r\n *\r\n * endsWith('abc', 'c')\r\n * // => true\r\n *\r\n * endsWith('abc', 'b')\r\n * // => false\r\n *\r\n * endsWith('abc', 'b', 2)\r\n * // => true\r\n */",
"meta": {
"range": [
563,
947
],
"filename": "endsWith.js",
"lineno": 23,
"path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
"code": {
"id": "astnode100002101",
"name": "endsWith",
"type": "FunctionDeclaration",
"paramnames": [
"string",
"target",
"position"
]
},
"vars": {
"undefined": null,
"position": "endsWith~position",
"end": "endsWith~end"
}
},
"description": "Checks if `string` ends with the given target string.",
"since": "3.0.0",
"tags": [
{
"originalTitle": "category",
"title": "category",
"text": "String",
"value": "String"
}
],
"params": [
{
"type": {
"names": [
"string"
]
},
"optional": true,
"defaultvalue": "''",
"description": "The string to inspect.",
"name": "string"
},
{
"type": {
"names": [
"string"
]
},
"optional": true,
"description": "The string to search for.",
"name": "target"
},
{
"type": {
"names": [
"number"
]
},
"optional": true,
"defaultvalue": "string.length",
"description": "The position to search up to.",
"name": "position"
}
],
"returns": [
{
"type": {
"names": [
"boolean"
]
},
"description": "Returns `true` if `string` ends with `target`,\r else `false`."
}
],
"see": [
"includes, startsWith"
],
"examples": [
"endsWith('abc', 'c')\r// => true\r\rendsWith('abc', 'b')\r// => false\r\rendsWith('abc', 'b', 2)\r// => true"
],
"name": "endsWith",
"longname": "endsWith",
"kind": "function",
"scope": "global",
"___id": "T000002R000228",
"___s": true,
"filepath": "endsWith.js"
}