A string is a data type in JavaScript. it is commonly wrapped around by either a single(’ ') or double (" ") quotation mark.
Assuming you have a variable which stores a string,
let variable='this is a string'
the computer will understand that it is just a string.
But if you want to quote something in the string above,
let variable='this "is" a string'
This will be confusing to the computer because it interpretes anything wrapped around by single or double quotation as a string. therefore, it will be seeing a string “is” inside another string which is not reasonable to it.
So to make the computer to understand that “is” is not a string, you have to place a backslash () before any quotation mark in a string. the variable above is written correctly as:
var variable='this \"is\" a string'
The computer will read this as:
this “is” a string
Notice the backslash coming before every quotation mark you dont want the computer to consider as a string.