Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #25956
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail |
|---|---|
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: JS Array problem |
| Date | Tue, 21 Oct 2014 13:12:25 +0200 |
| Organization | solani.org |
| Lines | 30 |
| Message-ID | <m25f2l$hks$1@solani.org> (permalink) |
| References | <calc4vFrm5iU1@mid.individual.net> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-15 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | solani.org 1413889941 18076 eJwFwQkBwDAIA0BLZDwFOTAa/xJ65xqI/1h4mNNZYk25a19hHARWc4cQKVcy8tSEGXvrdtYDFoQRDg== (21 Oct 2014 11:12:21 GMT) |
| X-Complaints-To | abuse@news.solani.org |
| NNTP-Posting-Date | Tue, 21 Oct 2014 11:12:21 +0000 (UTC) |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 |
| X-User-ID | eJwNx8ERACEIBLCWANmFKwdR+i/hnMknWFR2OEHHYBqT8dlTDbmJohzDTuW1sbNRLyuULtU2PxNtENI= |
| In-Reply-To | <calc4vFrm5iU1@mid.individual.net> |
| Cancel-Lock | sha1:w6xf7mOTlXpDjGNJEyWIPCO7cjs= |
| X-NNTP-Posting-Host | eJwFwYEBgDAIA7CXBCls51Cw/59ggjctpyKRAUHD2/sFLrVyI2cenW6vwsFiaO1+qmNDNP8BRAcSFQ== |
| Xref | csiph.com comp.lang.javascript:25956 |
Show key headers only | View raw
Mel Smith wrote:
> var a,b,c,d ;
>
> var abcd = [a,b,c,d] ;
>
> var somestr = "" ;
>
> for (var i= 0; i<abcd.length; i++) {
> somestr = i.toString() ;
> // I wish to place the current value of somestr in each
> // of the named but undefined objects/vrbls that are carried in the abcd
> array
>
> // e.g.,
> abcd[i] = somestr ; // but this, of course, ruins everything :(
>
> // what is the correct statement please ?
As you only want *undefined* values to be replaced, you have to check
for that:
if (typeof(abcd[i]) == "undefined") {
abcd[i] = somestr;
}
> }
--
Christoph M. Becker
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
JS Array problem "Mel Smith" <syntel@cox.net> - 2014-10-20 15:11 -0600
Re: JS Array problem Denis McMahon <denismfmcmahon@gmail.com> - 2014-10-20 22:25 +0000
Re: JS Array problem "Mel Smith" <syntel@cox.net> - 2014-10-21 08:33 -0600
Re: JS Array problem danca <cyberdanny@tiscalinet.it> - 2014-10-21 09:08 +0200
Re: JS Array problem Une Bévue <unbewusst.sein@fai.invalid> - 2014-10-21 09:42 +0200
Re: JS Array problem "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-10-21 09:47 +0200
Re: JS Array problem Une Bévue <unbewusst.sein@fai.invalid> - 2014-10-21 09:51 +0200
Re: JS Array problem "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-10-21 09:53 +0200
Re: JS Array problem Une Bévue <unbewusst.sein@fai.invalid> - 2014-10-21 09:52 +0200
Re: JS Array problem "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-10-21 10:36 +0200
Re: JS Array problem "Mel Smith" <syntel@cox.net> - 2014-10-21 08:36 -0600
Re: JS Array problem "Mel Smith" <syntel@cox.net> - 2014-10-21 08:35 -0600
Re: JS Array problem Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-10-21 19:02 +0200
Re: JS Array problem "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-10-21 13:12 +0200
Re: JS Array problem "Mel Smith" <syntel@cox.net> - 2014-10-21 08:38 -0600
Re: JS Array problem "Mel Smith" <syntel@cox.net> - 2014-10-21 08:29 -0600
My 'actual' code "Mel Smith" <syntel@cox.net> - 2014-10-21 11:20 -0600
Re: My 'actual' code Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-10-21 19:52 +0100
Re: My 'actual' code Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-10-21 21:23 +0200
Re: JS Array problem Violet Deng <dengviolet@gmail.com> - 2014-10-28 02:03 -0700
Re: JS Array problem "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-10-28 10:08 +0100
csiph-web