字符串
1、遍历接口
for(let code of 'foo'){ console.log(code) } // 'f' // 'o' // 'o'
2、判定一个字符串中是否包含另一个字符串
let aa = 'abcabc' aa.indexOf('abc') // 返回布尔值,是否包含 aa.includes('abc') // startsWith('abc') 是否以某一个字符串开始 // endsWith('abc') 是否已某一个字符串结束
3、repeat()
// 某一个字符串重复n次 'x'.repeat(3) // 'xxx'
4、padStart() padEnd() 字符串补全
// 接收2个参数,第一个指定最小长度,第二个参数用来补全的字符串 'x'.padStart(5, 'ab') // 'ababx'
浙公网安备 33010602011771号