大师网-带你快速走向大师之路 解决你在学习过程中的疑惑,带你快速进入大师之门。节省时间,提升效率

ES6几个好用的字符串操作方法

字符串查找

let a = 'liuyuanwai';
let b = 'ES6几个好用liuyuanwai的字符串操作';
document.write(b.includes(a))

判断是否在开头

let a = 'liuyuanwai';
let b = 'ES6几个好用liuyuanwai的字符串操作';
document.write(b.startsWith(a))

判断是否在结尾

let a = 'liuyuanwai';
let b = 'ES6几个好用liuyuanwai的字符串操作';
document.write(b.endsWith(a))

复制字符串

document.write('liuyuanwai-'.repeat(5));