Home  >  Q&A  >  body text

How to print a string in raw format (including all LINUX string representations like \t and \n) in JavaScript?

I have a string like this:

"string1\tstring2\n\t\tstring3"

I want to print a string in JavaScript. what should I do?

P粉009186469P粉009186469244 days ago334

reply all(1)I'll reply

  • P粉715274052

    P粉7152740522024-02-18 14:07:19

    You should use JSON.stringify()

    Example:

    JSON.stringify(string1  string2     string3)
    
    //console: string1\tstring2\t\tstring3

    reply
    0
  • Cancelreply