前端新手

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

2018-10-16  本文已影响1人  刘员外__

字符串查找

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));
上一篇下一篇

猜你喜欢

热点阅读