includes()、startsWith()和endsWith()
includes():返回布尔值,表示是否找到了参数字符串。
startsWith():返回布尔值,表示参数字符串是否在原字符串的头部。
endsWith():返回布尔值,表示参数字符串是否在原字符串的尾部。
let s ='He1lo world!' ;
s. startsWith( 'Hello') // true
s. endsWith('!') // true
s. includes('o') // true
let s ='He1lo world!' ;
s. startsWith( 'world',6) // true
s. endsWith('He1lo ',5) // true
s. includes('world',6) // true
注意:startsWith和includes的第二个参数表示从某个位置开始至最后,endsWith表示从前n个字符*