Lodash _.replace() Method
The _.replace() method replace the matches for pattern in string with replacement. This method is based on String#replace.
_.replace(string, pattern, replacement)
Parameters: This method accepts three parameters as mentioned above and described below:
- string: This parameter holds the original string.
- pattern: This parameter holds the pattern string that need to replace.
- replacement: This parameter holds the replacement string.
Return Value: This method returns the modified string.
Example 1: Here, const _ = require(‘lodash’) is used to import the lodash library in the file.