This following only replace first occurance of a string.
const str = "Replace all abc and abc."str.replace('abc', '0') // "Replace all 0 and abc."
Replace all string occurances.
str.replace(/abc/g, '0') // "Replace all 0 and 0."
or
const find = 'abc'const re = new RegExp(find, 'g')str.replace(re, '0')
Using function prototype
String.prototype.replaceAll = function(search, replacement) { return this.replace(new RegExp(search, 'g'), replacement)}
str.replaceAll("abc", "0")