Multi-line JavaScript

In a case of, “I didn’t know you could do that,” I discovered via some random blog post I’ve now lost track of, that you can do multi-line JavaScript by escaping the line breaks.

var a = ‘You can start here \
and continue here \
and then finish it up here.’;

The backslash on each line allows you to keep going. It’s a little bit cleaner than opening and closing quotes and a concatenation operator on each line.

And now’s your chance to say, “I can’t believe you didn’t know that.”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: