首页 > 其他分享 >字符串遍历器

字符串遍历器

时间:2022-10-16 01:58:34浏览次数:46  
标签:遍历 console na padStart repeat let 字符串

1.字符串可以通过for...of进行遍历字符.
2.遍历器可以识别大于0xFFFF的码点,传统的for无法识别这样的码点

let text = String.fromCodePoint(0x20BB7);
for (let i = 0; i < text.length; i++) {
  console.log(text[i]);
}
// " "
// " "
for (let i of text) {
  console.log(i);
}
// "

标签:遍历,console,na,padStart,repeat,let,字符串
From: https://www.cnblogs.com/mengyiqwq/p/16795478.html

相关文章