阅读(4559) (0)

Lodash _.startsWith

2021-09-23 14:42:36 更新

_.startsWith([string=''], [target], [position=0]) 

检查字符串string是否以 target 开头。

添加版本

3.0.0

参数

  1. [string=''] (string): 要检索的字符串。
  2. [target] (string): 要检查的字符串。
  3. [position=0] (number): 检索的位置。

返回

(boolean): 如果string以 target,那么返回true,否则返回 false 。

例子

_.startsWith('abc', 'a');
// => true 
_.startsWith('abc', 'b');
// => false
 _.startsWith('abc', 'b', 1);
// => true