Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #28565

Re: Javascript

Path csiph.com!news.mixmin.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: Javascript
Date Mon, 24 Aug 2015 22:45:41 +0200
Organization PointedEars Software (PES)
Lines 49
Message-ID <12751526.7etGybu6s3@PointedEars.de> (permalink)
References <d43956e8-6f1d-431d-a45e-7845adf014ac@googlegroups.com> <XnsA4FF7286FD0DEeejj99@194.109.6.166>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding 8Bit
X-Trace solani.org 1440449356 21402 eJwNykkBwDAIBEBLnBuQEyj4l9DMe1zB6GNwmK8vJYdvfa2Sl7uVZyF1Kcomgs5gUl6ffD31Bx3hEOM= (24 Aug 2015 20:49:16 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Mon, 24 Aug 2015 20:49:16 +0000 (UTC)
User-Agent KNode/4.14.2
X-User-ID eJwFwYEBwDAEBMCVCE9+HKH2H6F3sNDo9EA4FtuwnKU/oZWjhA93ZrVDIVzSUEg7HEmrq7j7pOzoaPZXP0KlFQQ=
Cancel-Lock sha1:fJoXD+JYxoOUXBHlSGRx8tZlzA0=
X-NNTP-Posting-Host eJwNx8kBwCAIBMCWWIVVyuGQ/ktI5je2CdZRGtXGJiEPiP7D5hJLva88roW3FjIgs0U8jq56/AAeOxEZ
Xref csiph.com comp.lang.javascript:28565

Show key headers only | View raw


Evertjan. wrote:

> dil.nandoo@gmail.com wrote on 23 Aug 2015 in comp.lang.javascript:
>> <link type="text/css" rel="stylesheet" href="http://paste/map.css" />
> 
> http://paste/ ???
> 
> Is that a usable URL?

Probably yes, but not for the general public.
 
> "/>" are you using XML? Why?

You are jumping to conclusions.  This is also Valid HTML5 syntax for the 
“link” element, although the “/” is optional when one is not using the XHTML 
syntax of HTML5.

>> for (i = 0; i <image_qtd; i++) {
> 
> image_qtd is that defined somewhere?

More important: Is “i” declared?  If not, this code will not run in strict 
mode.
 
>>     var preload = new Image();
> 
> You are doing a var on every instance of the for,
> once is enough, because for does not make a closure.

Variables are instantiated once as execution enters a context, and because 
the default scope is the execution context, not the Block statement (cf. 
“let”), there is no intrinsic problem with putting the “var” statement in 
the block adjacent to the “for” statement.  Only that sometimes it is better 
to declare a variable outside of the Block statement to see the relation 
better if the variable is also used outside of the Block statement.

Some advocate declaring all variables on the top of an execution context, 
some based on having an ill-defined notion of “hoisting”.  I prefer to 
declare my variables as close as possible to where they are first used, and 
let linters take care of the rest (such as unused variables); which in the 
case of a variable that is only used in a “for” loop to declare it in the 
“for” statement or near the top of the adjacent Block statement, precisely 
as the OP did.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Javascript dil.nandoo@gmail.com - 2015-08-22 20:03 -0700
  Re: Javascript "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-08-23 11:15 +0200
    Re: Javascript "Ralf S. Hellersen" <schneiderxr@arcor.de> - 2015-08-24 20:07 +0000
      Re: Javascript "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-08-24 23:49 +0200
    Re: Javascript Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-08-24 22:45 +0200
  Re: Javascript dil.nandoo@gmail.com - 2015-08-24 14:57 -0700

csiph-web