美文网首页
【JS ES6】String

【JS ES6】String

作者: 大Q本Q | 来源:发表于2019-07-08 10:42 被阅读0次
/* 是否包含't'
 * 是否'i'开头
 * 是否'i'结尾
 */
'cai'.includes('i');        // -> false     
'cai'.startsWith('i');      // -> false
'cai'.endsWith('i');        // -> true
// 重复
'cai'.repeat(3);            // -> caicaicai
// 字符串补全长度
'o'.padStart(4,'strin')     // -> stro
'o'.padEnd(4,'st')          // -> osts
// 字符串模板
let name = 'cai';
let descrition = `My name is ${name}` // -> My name is cai
// 恢复转义符
String.raw

相关文章

网友评论

      本文标题:【JS ES6】String

      本文链接:https://www.haomeiwen.com/subject/nwonhctx.html