replace i javascript code example
Example 1: javascript replace
var res = str.replace("find", "replace");
Example 2: how to use the replace method in javascript
let string = 'soandso, my name is soandso';
let replaced = string.replace(/soandso/gi, 'Dylan');
console.log(replaced); //Dylan, my name is Dylan
Example 3: replace js
// Replace All
str = str.replace(/_/g, ' ');