Skip to content

endsWith

js
_.endsWith([string=''], [target], [position=string.length])

检查 string 是否以给定的目标字符串结尾。

¥Checks if string ends with the given target string.

新增于

¥Since

3.0.0

参数

¥Arguments

  1. [string=''] (字符串):要检查的字符串。

    ¥[string=''] (string): The string to inspect.

  2. [target] (字符串):要搜索的字符串。

    ¥[target] (string): The string to search for.

  3. [position=string.length] (数值):要搜索到的位置。

    ¥[position=string.length] (number): The position to search up to.

返回

¥Returns

(布尔):如果 stringtarget 结尾,则返回 true,否则返回 false

¥(boolean): Returns true if string ends with target, else false.

示例

¥Example

js
_.endsWith('abc', 'c');
// => true

_.endsWith('abc', 'b');
// => false

_.endsWith('abc', 'b', 2);
// => true

Lodash v4.17 中文网 - 粤ICP备13048890号