To replace all occurrences of specified character
replace() method on the string, and pass the specific character
ch as regular expression with global search
/ch/g, and an empty replacement string
'', as arguments.
With this setup,
replace() method returns a new string with all the occurrences of the specified character
ch removed from the given string.
1. Given string value is in
str. Remove all the occurrences of the character
'a' from the string
let str = 'apple banana cherry'; let output = str.replace(/a/g, ''); console.log(output);