ES6下新增4中字符串方法,更加方便我们处理问题
//ES5下判断字符串存在不存在某个字符,indexOf 返回-1不存在,否则返回位置
console.log('string'.indexOf('i')==-1);
1.ES6新增方法 includes方法.存在返回ture
console.log('jding'.includes('a'));
2.ES6 重复字符串 repeat(n),重复目标字符串n次
console.log('ha '.repeat(5))
3.判断字符串开头是否包含 startsWith()
console.log('ytessdds'.startsWith('yt'));
4.判断字符串结束是否包含 endsWith()
console.log('ytessdds'.endsWith('dds'));