JavaScript检测一个字符串是否包含一个子字符串
2021-07-20
js旧版本ECMAScript 5
let a = 'Hello World';
let b = 'World';
let result = a.indexOf(b) !== -1;
console.log(result); // true;
新版本ECMAScript 6
let a = 'Hello World';
let b = 'World';
let result = a.includes(b);
console.log(result); // true;
(版权归cpury.com所有,转载请注明出处。)