使用es6的startsWith和endsWith方法
let str='postedit';
if(str.startsWith('po')){
alert('开头正确');
}else if(str.endsWith('it')){
alert('结束正确');
}
使用es6的startsWith和endsWith方法
let str='postedit';
if(str.startsWith('po')){
alert('开头正确');
}else if(str.endsWith('it')){
alert('结束正确');
}