str.replace(/a/g, "b");
  • The codes will replace all "a" with "b".
  • The first parameter is a regular expression (regex).