Multiline string issue in javascript

It works:

alert('foo\
         bar'
)

But this causes a syntax error:

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

error:

SyntaxError: unterminated string literal

They must be the same, why does the first one work, and the second one fails?

+5
source share
1 answer

You have backspace after backslash in the second example.

+3
source

All Articles