Multiline strings in JavaScript

I used to write multiline strings in JavaScript like this:


var str = 'This is ' +
'a very long ' +
'sentence.'

Sometimes, i wrote it this way:

var str = ['This is ',
'a very long ',
'sentence.'].join('');

Using array to contact strings is an effective way. I also see an implement of StringBuilder in JavaScript using this technology.

Today, i was surprised to find the third way:

var str = 'This is \
a very long \
sentence.';

just cool!

你可能感兴趣的:(JavaScript)