I am using node.js v14.18.1 and here is what I got (after shrinking my code down to a single line):
console.log("anything".replaceAll("a","a"));
^
TypeError: "anything".replaceAll is not a function
Though it's working in a developer.mozilla.org snippet box. Any idea?
CodePudding user response:
String#replaceAll()
only works on version Node version 15.0.0 and above, according to Node Green.
CodePudding user response:
Replace all is implemented after node 15.0.0.
You can use the following to replace all
"anything".replace(/a/g, "b");