以前javascript中判断子串,就用indexof了,比如:
var str = "test";
if (str.indexOf('te') > -1) {
console.log('match')
} else {
console.log('not found')
}
ES6中,用include就可以了:
var str = "test";
console.log(str.includes('te')); //true