includes():判断母串中是否包含子串,如果包含,返回true,否则返回false。
let str="http://192.168.1.51.jpg";
if(str.includes('.jpg')){
console.log('ok');
}
starsWith():母串中是否以“XX”开头:是 true,否 false;
let str="http://192.168.1.51.jpg";
if(str.startsWith('http')){
console.log('ok');
}
endsWith():母串中是否以“XX”结尾:是 true,否 false;
let str="http://192.168.1.51.jpg";
if(str.endsWith('.jpg')){
console.log('ok');
}