javascript escape backslash code example
Example 1: javascript string remove backslash
string.replace(/\\\//g, "/");
Example 2: javascript backslash
You have to type a double backslash. Like: \\
Example 3: escape in javascript
escape sequences in javascript
\' single quote
\" doucle quote
\\ backslash
\n newline
\r carriage return
\t tab
\b backspace
\f form feed
Example 4: add a slash to string in javascript
var str = 'USDYEN'
// add a / in between currencies
// var newStr = str.slice(0, 3) + ' / ' + str.slice(3)
// var newStr = str.slice(3) // removes the first 3 chars
// var newStr = str.slice(0,3) // removes the last 3 chars
var newStr = str.slice(0,3) + ' / ' + str.slice(3) // removes the first 3 and adds the last 3
console.log(newStr)
// => USD / YEN