Search code examples
javascriptstringterminate

Alternative string terminate


I just wanted to ask, if there are some alternative (different than quotes) string terminators in Javascript? I've heard about the NULL byte that used to work on IE.

I know that a string can't be over 1 line because the next line is treated as next line of code, however in this case javascript just reports "unterminated string" error.

Thank you!


Solution

  • You can either escape the newline:

    var a = "beginning of string\
    

    rest of string";

    or you can use string concatenation:

    var a = "beginning of string" +
            "rest of string";