This is going to be a pretty quick post (mainly because I am on vacation, next week). I was skimming through what is new in ECMAScript 2021 and spotted replaceAll(). It is already supported in everything except for Internet Explorer. Let’s take a look at a quick example.
See the Pen
String.prototype.replaceAll() Example by Joe Steinbring (@steinbring)
on CodePen.
The reference is within computed properties but this definitely does not require vue. As you can see, it works the same as replace() but it just doesn’t stop at the first instance.
Have any questions, comments, etc? Feel free to drop a comment, below.
[ Cover photo by Jamie Street on Unsplash ]