How to replace all of JavaScript
This article mainly introduces how to achieve full replacement of JavaScript, with a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
Replace all
The String.replace () function allows you to replace strings with String and Regex, and this function itself can only replace the first matching string. But you can add / g to the end of the regular expression to simulate the replaceAll () function:
Var string = "john john"; console.log (string.replace (/ hn/, "ana")); / / "joana john" console.log (string.replace (/ hn/g, "ana")) / / "joana joana" Thank you for reading this article carefully. I hope the article "how to replace all JavaScript" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!