JavaScript string method replace(): replacing text with a regular expression

String.prototype.replace() is one of the more useful methods — you reach for it whenever you need to replace something inside a string. We work through it on a real example.

Read next