Je Rog
Je Rog

Reputation: 6031

Have problem with multi-line string in javascript

This works:

alert('foo\
         bar'
)

But this is causing syntax error:

t='test';
alert('<tr><td><b>' + t + '</b></td>\ 
                    <td></td><td>')

error is:

SyntaxError: unterminated string literal

They two should be the same thing, why the first one works, while the second fails?

Upvotes: 5

Views: 216

Answers (1)

Daniel Brockman
Daniel Brockman

Reputation: 19290

You have a trailing space after your backslash in the second example.

Upvotes: 3

Related Questions