W3C home > Mailing lists > Public > public-webapi@w3.org > June 2007

Re: [selectors-api] Minor comments on the spec text

From: Magnus Kristiansen <magnusrk+w3c@pvv.org>
Date: Mon, 25 Jun 2007 20:43:30 +0200
To: public-webapi@w3.org
Message-ID: <op.tuhqasjze26bmd@tzeentch.studby.ntnu.no>

On Mon, 25 Jun 2007 18:03:40 +0200, Lachlan Hunt  
<lachlan.hunt@lachy.id.au> wrote:

> Philip Taylor wrote:
>> I'd also remove the "var rows = null;" and put the "var" inside the  
>> loop to simplify the code, though perhaps that's a bad idea because JS  
>> scoping is weird.
> Correct me if I'm wrong, but if it were declared inside the loop, the  
> variable would be destroyed and reallocated in memory for every loop. By  
> declaring it outside, it just allocates it once, which is more efficient.

Javascript doesn't have scope more fine-grained than function. You could  
even declare the variable after the loop and it would run just the same.  
For readability (indicating the variable is only intended to be used  
inside the loop), var-ing it inside the loop would probably be best. Not  
all that much point in optimizing an example just intended to show the  
select* methods are superior, though.

Magnus Kristiansen
"Don't worry; the Universe IS out to get you."
Received on Monday, 25 June 2007 18:45:41 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:16:23 UTC