Line continuation characters in JavaScript

javascript

Solution

If I properly understood your question:

var statement = con.createStatement('select * from t where '
                                  + '(t.a1 = 0 and t.a2 >=-1) '
                                  + 'order by a3 desc limit 1');

For readability, it is fine to align `+` operator on each row: Anyway, unless you're using Ecmascript 2015, avoid to split a multiline string with `\`, because:

- It's not standard JavaScript

- A whitespace after that character could generate a parsing error

Problem

What is the best practice for line continuation in JavaScript? I know that you can use `\` for strings. But how would you split the following code? ``` var statement = con.createStatement("select * from t where (t.a1 = 0 and t.a2 >=-1) order by a3 desc limit 1"); ```

Original source

Related problems