• 9 条非常强大的 JavaScript 技巧

    1、全部替换我们知道string.replace()函数只会替换第一次出现的位置。在正则表达式末尾添加 /g 即可替换所有出现。varexample="potatopotato";console.log(example.replace(/pot/,"tom"));//"tomatopotato"console.log(example.replace(/pot/g,"tom"))...

    Javascript 2019年12月30日 1433 0