Full Stack LAMP - MEAN Developer, Python developer. Certified Azure Developer. Freelance programmer/consultant/trainer.

Javascript – replaceAll

String.prototype.replaceAll provides an easy way to replace all occurrences of a substring without creating a global RegExp.

const queryString = 'q=query+string+parameters';

// Works, but requires escaping inside regular expressions.
queryString.replace(/\+/g, ' ');
// → 'q=query string parameters'

// Simpler!
queryString.replaceAll('+', ' ');
// → 'q=query string parameters'

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments