js special characters in string code example

Example 1: js escape characters

JS Escape Characters
\' — Single quote
\" — Double quote
\\ — Backslash
\b — Backspace
\f — Form feed
\n — New line
\r — Carriage return
\t — Horizontal tabulator
WebsiteSetup.org - Beginner’s Javascript Cheat Sheet 7
\v — Vertical tabulator

Example 2: 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 3: 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