Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #24067
| From | Dr J R Stockton <reply1400@merlyn.demon.co.uk.invalid> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Strings with trailing plus |
| Date | 2014-05-09 12:40 +0100 |
| Organization | Home |
| Message-ID | <7fLY8UVy6LbTFwYV@invalid.uk.co.demon.merlyn.invalid> (permalink) |
| References | <T72dnUGM8ZJAb_vOnZ2dnUVZ_g2dnZ2d@westnet.com.au> |
In comp.lang.javascript message <T72dnUGM8ZJAb_vOnZ2dnUVZ_g2dnZ2d@westne t.com.au>, Mon, 5 May 2014 12:07:56, Andrew Poulos <ap_prog@hotmail.com> posted: >I typically concatenate long stings with trailing spaces and plus signs eg. > >var str = "blah blah... blah " + > "blah blah... blah " + > "blah blah... blah " + > "blah blah... blah " + > "blah blah... blah"; > >but I've seen code with leading plus signs and spaces eg. > >var str = "blah blah blah" > + " blah blah... blah" > + " blah blah... blah" > + " blah blah... blah" > + " blah blah... blah"; > >Is their a reason to prefer one over the other? Yes. With a trailing + it is immediately obvious to a human reader of the line, without looking ahead, that there is a continuation. That applies particularly in the case of a single continuing line; with many continuing lines, the overall structure will be noticed peripherally while the first line is being considered - if they are on-screen. JavaScript treats them the same, although there may be a very small browser-dependent speed difference at the parsing stage. Obviously you can measure that well enough to see whether it is significant. -- (c) John Stockton, Surrey, UK. ¬@merlyn.demon.co.uk Turnpike v6.05 MIME. Web <http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links. Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036) Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread
Strings with trailing plus Andrew Poulos <ap_prog@hotmail.com> - 2014-05-05 12:07 +1000
Re: Strings with trailing plus "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2014-05-05 08:08 +0300
Re: Strings with trailing plus Christoph Michael Becker <cmbecker69@arcor.de> - 2014-05-05 13:02 +0200
Re: Strings with trailing plus Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-05 19:45 +0200
Re: Strings with trailing plus Andrew Poulos <ap_prog@hotmail.com> - 2014-05-09 11:39 +1000
Re: Strings with trailing plus Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-09 10:13 +0200
Re: Strings with trailing plus Norman Peelman <npeelman@cfl.rr.com> - 2014-05-09 22:43 -0400
Re: Strings with trailing plus Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-09 10:11 +0200
Re: Strings with trailing plus Dr J R Stockton <reply1400@merlyn.demon.co.uk.invalid> - 2014-05-09 12:40 +0100
csiph-web