How to globally replace a forward slash in a JavaScript string?
You can create a RegExp object to make it a bit more readable
RegExp
str.replace(new RegExp('/'), 'foobar');
If you want to replace all of them add the "g" flag
"g"
str.replace(new RegExp('/', 'g'), 'foobar');