zl程序教程

您现在的位置是:首页 >  后端

当前栏目

js ES6字符串的新功能

ES6JS 功能 字符串
2023-09-27 14:26:02 时间

ES6新增了字符串的遍历器接口,使得字符串可以被for of循环遍历。

for(let v of 'abcdefg'){
  console.log(v)
}
检索字符串中的所有数字:
let str = 'a,b,c,d,e,f,g,1,2,3'
console.log(str.match(/\d+/g))