One of my colleagues used backslashes when setting the string value of a property in a JS object:
shareButtonsHtml : '\
<span class="share-fb">\
<a href="#" class="fb-share"><span class="fb-share-icon"></span>Share</a>\
<span class="fb-share-count"><i></i><u></u>0</span>\
</span>\
<div class="share-twitter"> \
<iframe class="share-twitter-iframe" \
allowtransparency="true" frameborder="0" scrolling="no" \
src="https://platform.twitter.com/widgets/tweet_button.html" \
style="width:130px; height:20px;"></iframe> \
</div> \
<div class="share-google"> \
<div class="g-plusone" data-size="small" data-annotation="none"></div> \
</div>',
The only thing we do with this string is populate our social share buttons container when the user mouseovers them:
self.html(obj.shareButtonsHtml);
I know backslash is an escape character in JS. Can anyone explain why my colleague used them here? Surely he didn't need to escape the carriage return or line break? He's since moved on to another company, so I can't ask him!