我试图在 JavaScript 中将字符串打印为字符串文字,以便字符串将完全按照其编写方式打印:
printStringLiteral("\n\nHi!");//this prints "Hi!" instead of "\n\nHi!".
//What will I need to do in order to print
//the string as a string literal instead?
function printStringLiteral(toPrint){
console.log("\"" toPrint + "\"");
}