html escape single quote javascript code example
Example 1: javascript escape quote method
stringToEscape.replace(/"/g, '\\\"')
Example 2: javascript escape single quote
var string = 'this isn\'t a double quoted string';
var string = "this isn\"t a single quoted string";
// ^ ^ same types, hence we need to escape it with a backslash