Checks if `string` starts with the given target string.
startsWith('abc', 'a')
// => true
startsWith('abc', 'b')
// => false
startsWith('abc', 'b', 1)
// => true
| Name | Type | Attribute | Description |
|---|---|---|---|
| string | The string to inspect. | ||
| target | The string to search for. | ||
| position | The position to search from. |
{
"comment": "/**\r\n * Checks if `string` starts 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=0] The position to search from.\r\n * @returns {boolean} Returns `true` if `string` starts with `target`,\r\n * else `false`.\r\n * @see endsWith, includes\r\n * @example\r\n *\r\n * startsWith('abc', 'a')\r\n * // => true\r\n *\r\n * startsWith('abc', 'b')\r\n * // => false\r\n *\r\n * startsWith('abc', 'b', 1)\r\n * // => true\r\n */",
"meta": {
"range": [
558,
885
],
"filename": "startsWith.js",
"lineno": 23,
"path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
"code": {
"id": "astnode100008786",
"name": "startsWith",
"type": "FunctionDeclaration",
"paramnames": [
"string",
"target",
"position"
]
},
"vars": {
"undefined": null,
"position": "startsWith~position",
"target": "startsWith~target"
}
},
"description": "Checks if `string` starts 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": 0,
"description": "The position to search from.",
"name": "position"
}
],
"returns": [
{
"type": {
"names": [
"boolean"
]
},
"description": "Returns `true` if `string` starts with `target`,\r else `false`."
}
],
"see": [
"endsWith, includes"
],
"examples": [
"startsWith('abc', 'a')\r// => true\r\rstartsWith('abc', 'b')\r// => false\r\rstartsWith('abc', 'b', 1)\r// => true"
],
"name": "startsWith",
"longname": "startsWith",
"kind": "function",
"scope": "global",
"___id": "T000002R000798",
"___s": true,
"filepath": "startsWith.js"
}