字符串的扩展
1、字符串遍历
for(let i of 'foo'){
console.log(i);
}
// 'f' 'o' 'o'
2、扩展方法
at()
'at'.at(0) // 'a'
**includes(),startsWith(),endsWith()
var s = 'HelloWorld';
s.startWith('Hello');true
s.endWith('Hello',5);//从第几个位置开始搜索
s.includes('o');//true
repaet()
'hello'.repeat(2);//'hellohello'
padStart(),padEnd()
'x'.padStart(5,'ab');//'ababx'
'x'.padEnd(5,'ab');//'xaba'
3、模板字符串
var name = 'zhangsan';
var text = `ni hao ${name} `\`,hi!`;