3、字符串的扩展及新增方法
#一、字符串新增了遍历器接口
字符串新增了遍历器接口 《Interator》, 使得字符串可以被 for…of 循环遍历。
for (let ererycode of "foo") {
console.log(ererycode);
}
// "f"
// "o"
// "o"
#二、新增了模版字符串
传统的 Javascript 中,输出模版通常是下面写法
$(#result).append(
'There are <b>'+basket.count+'</b>'+
'<em>'+basket.data+'</em>'
)
非常的繁琐,新增模版字符串
$(#result).append(
`There are
<b>${
basket.count}</b>
<em>${
basket.data}</em>`
)
//