Question:medium

What is the key difference between the JavaScript string methods replace() and replaceAll()? Support your answer with an example.

Show Hint

Warning! If you pass a regular expression to replaceAll(), it must contain the global (/g) flag. If the global flag is missing, JavaScript will throw a TypeError: replaceAll must be called with a global RegExp.
Updated On: Jun 29, 2026
Show Solution

Solution and Explanation

Was this answer helpful?
0