rafaelmaeuer
1/25/2018 - 2:51 PM

How to replace all occurrences of a string in JavaScript?

String.prototype.replaceAll = function(search, replacement) {
    var target = this;
    return target.split(search).join(replacement);
};