replaceAll is actually a relatively recent addition to JS and probably is not the main method used in a lot of JS libraries - and certainly is not the only method. The original way to do a 'replace all' is just with replace - the following would be the same as your example:
replaceAll
is actually a relatively recent addition to JS and probably is not the main method used in a lot of JS libraries - and certainly is not the only method. The original way to do a 'replace all' is just withreplace
- the following would be the same as your example:Note the
g
at the end of the regular expression - making it a global match on the stringThis is great to know. Thanks for the feedback!