0

Hi, sometimes we have to add paragraphs or large amounts of text to a javascript variable. Usually we want to break the var in various lines for better code reading and end up concatenating using:

        var x = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'+
        'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'+ 
        'cccccccccccccccccccccccccccccccccc' +
        'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'+
        'cccccccccccccccccccccccccccccccccc' +
        'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'+ 
        'cccccccccccccccccccccccccccccccccc' +
        'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'+
        'cccccccccccccccccccccccccccccccccc' +

Is there any better method, minding code reading, to concatenate large amounts of text in javascript? Another problem is that when we use 'auto format', the text editor/ide usually put the strings all together in the same line.

Renato Probst
  • 5,914
  • 2
  • 42
  • 45

0 Answers0