let str = 'abcdeedcba'
for(let i in str){
console.log(str[i]) // a b c d e e d c b a
}
for ofincludes()、startsWith()、endsWith()
at()方法是es6新增的查看字符串指定位置字符的方法;
at()方法接受一个整数作为参数,返回参数指定位置的字符,支持负索引(即倒数的位置)。
const str = 'hello';
str.at(1) // "e"
str.at(-1) // "o"
如果参数位置超出了字符串范围,at()返回undefined。