JavaScript String replace vs replaceAll
From gleaning the documentation for replaceAll, we find the following tidbits: const newStr = str.replaceAll(regexp|substr, newSubstr|function) Note: When using a regexp you have to set the global (“g”) flag; otherwise, it will throw a TypeError: “replaceAll must be called with a global RegExp”. In other words, when calling replaceAll with a regex literal or RegExp, … Read more