字符串模板
var str = '名字';var long = '开开心心的学习es6的字符串模板语法'document.write(long)复制代码
字符串查找 indexOf
console.log(long.indexOf('开心')) // 1复制代码
字符串是否存在 includes
console.log(long.includes('开心')) // true复制代码
运算
var a = 1, b = 2;var c = ` ${a + b} `document.write(c) 复制代码
判断开头是否存在 startsWith
console.log(long.startsWith('开心')) // false复制代码
判断结尾是否存在 endsWith
console.log(long.endsWith('开心'))复制代码
字符串复制
console.log(long.repeat(2))复制代码