Java, which had served an inspiration for JavaScript in the first days, has the replaceAll() method on strings since 1995 ! In this post, you’ll learn how to replace all string occurrences in JavaScript by splitting and joining a string, and string. replace() combined with a global regular expression.