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!

posted @ 2009-05-05 17:25  三生石上(FineUI控件)  阅读(325)  评论(1编辑  收藏  举报