Convert string to JavaScript code

input
variable(string)

string

output(string)

The function of this online utility is to convert string to JavaScript code.

For example, if the variable is t and the string is:

line "1"
line '2'
line 3:\test1\test2
then the output will be:
var t = '';
t += 'line "1"' + '\r\n';
t += 'line \'2\'' + '\r\n';
t += 'line 3:\\test1\\test2';

Share: