bhylu.com

Advertisements

JS 2021

ReplaceAll changes every matching plain-string occurrence. It avoids building a regular expression just to replace fixed text.

Where to run this

This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.

A practical example

JavaScript

console.log("club / club".replaceAll("club", "workshop"));

What happens

Both occurrences become workshop.