Javascript replace() Reference

Description:
Searches for a string using regex and replaces string that matches.

Syntax:

string.replace(searchvalue,newvalue)

Examples:

var str = "Dude, where's my car?";
var res = str.replace("Dude", "Bro");
console.log(res); // Bro, where's my car?

To replace all instances:

var str = "Dude, Dude, Dude, where's my car?";
var res = str.replace(/Dude/g, "Bro");
console.log(res); // Bro, Bro, Bro, where's my car?