主题
endsWith
js
_.endsWith([string=''], [target], [position=string.length])
检查 string
是否以给定的目标字符串结尾。
¥Checks if string
ends with the given target string.
新增于
¥Since
3.0.0
参数
¥Arguments
[string='']
(字符串):要检查的字符串。¥
[string='']
(string): The string to inspect.[target]
(字符串):要搜索的字符串。¥
[target]
(string): The string to search for.[position=string.length]
(数值):要搜索到的位置。¥
[position=string.length]
(number): The position to search up to.
返回
¥Returns
(布尔):如果 string
以 target
结尾,则返回 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