Is there a way to replace all occurrences in string giving an array as a parameter in replace() method.
For example:
Having this string: "ABCDEFG"
And having this array: ['A','D','F']
It is possible to replace the same letters in the string with something else? Something like:
"ABCDEFG".replace(['A','D','F'], '')
So the final result be: "BCEG"
"ABCDEFG".replace(/A|D|F/g, '')would be fine, or it has to be dynamic with the array ?replacemethod (given you don't want to touch the prototype). You could write your own function, though