How do I replace all occurrences of a string in JavaScript?

asked16 years ago
last updated3 years ago
viewed4.4m times
Up Vote5.4kDown Vote

Given a string:

s = "Test abc test test abc test test test abc test test abc";

This seems to only remove the first occurrence of abc in the string above:

s = s.replace('abc', '');

How do I replace occurrences of it?