Re: [jslint] Method operations on string literals in concatenation chains
- Most recently, I've been doing a lot of embed codes (object + params + embed). I break them into multiple lines to aid readability, as they tend to be quite long and would wrap in odd places.
----- Original Message -----
From: Erik Eckhardt <erik@...>
Sent: Thursday, 7 July 2011, 8:37
Subject: Re: [jslint] Method operations on string literals in concatenation chains
Why concatenate string literals together, anyway?
A = "a" + "b" + "c".replace();
seems like it simply ought to be:
A = "abc".replace();
Perhaps it is multi-line strings that introduce bugs more than improper
parentheses for the replace function.
On Thu, Jul 7, 2011 at 12:53 AM, Luke Page <luke.a.page@...> wrote:
> You have to be concatenating a massive number of strings for that to make
> real world difference. Otherwise it is just needlessly complicating things.
> Ideally for best clarity and separation your html template will be defined
> separate from your template mechanism and separate from logic generating
> your replacement values.
> Partly because of this I can't think of any times I've seen a bug along
> these lines. The most common intention in code I've seen would be the case
> you don't want! I would rather be forced to write
> A = "b"+"c";
> A = A.x();
> For your case and I certainly don't think it looks nice having to write
> A = "b" + ("c").x();
> You might as well require every expression have brackets to ensure the
> programmer doesn't have a bad knowledge of operator precedence (which I
> already do in non obvious cases). I'd consider this a reasonably obvious
> What do people think about operator precedence / bracket usage in general -
> are there any rules everyone agrees would be useful?
> On 7 Jul 2011 07:49, "Rob Richardson" <erobrich@...> wrote:
> [Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
Yahoo! Groups Links