es6数组方法

1.includes():返回布尔值,表示是否找到了参数字符串。

2.startsWith():返回布尔值,表示参数字符串是否在原字符串的头部。

3.endsWith():返回布尔值,表示参数字符串是否在原字符串的尾部。

实例:

let s = 'Hello world!';

 

s.startsWith('Hello') // true

s.endsWith('!') // true

s.includes('o') // true

 

第二参数 

let s = 'Hello world!';

 

s.startsWith('world', 6) // true

s.endsWith('Hello', 5) // true

s.includes('Hello', 6) // false

  

猜你喜欢

转载自www.cnblogs.com/Longhua-0/p/9317196.html
今日推荐