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


Groups > comp.lang.javascript > #27101

Re: Reach a digit of numerical value in array index.

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!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: Reach a digit of numerical value in array index.
Date Sun, 22 Mar 2015 16:29:03 +0100
Organization PointedEars Software (PES)
Lines 37
Message-ID <8127222.NEJAP2j12Q@PointedEars.de> (permalink)
References <7bb55099-4d9b-46e0-b4b7-3785304be4f4@googlegroups.com> <medgv0$gjb$1@dont-email.me> <49b891b6-283a-45ed-beec-3cdc19983595@googlegroups.com> <9k5lgatqlm6esvojkhsntbcdpk58ma2gka@4ax.com> <2641901.31sAzN5gEV@PointedEars.de> <fbSfNlNPJLDVFwke@invalid.uk.co.demon.merlyn.invalid>
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 1427038243 14851 eJwFwYEBwCAIA7CXhNE6zpnF/n/CEjwMahfBguEB3HxHrWz4HsldQi4kejF82en65qjC+QMoTRF2 (22 Mar 2015 15:30:43 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Sun, 22 Mar 2015 15:30:43 +0000 (UTC)
User-Agent KNode/4.14.2
X-User-ID eJwVxccRBEEIA8CUMBIw4TCG/EPYu+pH00PjJIIBzl+84W4p6g3f6VKgdGG1T8moWdtbZxS/5+bWO2e5vSQaH04pFY4=
Cancel-Lock sha1:yg3M5VNi95+TZCNlcDXvFFY+Kno=
X-NNTP-Posting-Host eJwNycERACEIA8CWlAA5ygGd9F+Ct98N5M5Dz0gPhXJsRjj9FZ1/0vaAXOaXgrpgci5cq4bmARCSEKI=
Xref csiph.com comp.lang.javascript:27101

Show key headers only | View raw


Dr J R Stockton wrote:

> [A long time ago, in a galaxy far, far away] Thomas 'PointedEars' Lahn 
> [posted this story: ]

When will you stop posting those attribution novels?

> Consider and test
> 
> 
>         j = 3
>         n = 12345 ; X = (n % Math.pow(10, j)).toString().charAt(0)
>         n = 12045 ; Y = (n % Math.pow(10, j)).toString().charAt(0)
>         n = 00345 ; Z = (n % Math.pow(10, j)).toString().charAt(0)
>         Z = [X, Y, Z]        ///// ->    3, 4, 2

Right, you would need to pad the toString() result if the result of the “%” 
operation would be smaller than the 1-based index (j).  I *did* test this 
approach before posting it – even though I also *did* point out *twice* that 
it is error-prone –, but not with such numbers.

> in which Z is present for amazement/amusement only.

Numeric integer literals with leading zero are parsed as octal in Mozilla 
JavaScript (and not a syntax error) when not in strict mode.  No surprise 
here.

> **TESTED** in current Firefox.

Confirmed in Iceweasel 31.5.0 (“current” is not a sensible designation, 
especially not with rapid releases).

-- 
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

Reach a digit of numerical value in array index. jonas.thornvall@gmail.com - 2015-03-17 14:15 -0700
  Re: Reach a digit of numerical value in array index. jonas.thornvall@gmail.com - 2015-03-17 14:34 -0700
    Re: Reach a digit of numerical value in array index. JJ <jj4public@vfemail.net> - 2015-03-18 13:38 +0700
      Re: Reach a digit of numerical value in array index. jonas.thornvall@gmail.com - 2015-03-18 06:57 -0700
  Re: Reach a digit of numerical value in array index. Norman Peelman <npeelman@cfl.rr.com> - 2015-03-18 23:49 -0400
    Re: Reach a digit of numerical value in array index. jonas.thornvall@gmail.com - 2015-03-19 01:16 -0700
      Re: Reach a digit of numerical value in array index. John Harris <niam@jghnorth.org.uk.invalid> - 2015-03-19 09:28 +0000
        Re: Reach a digit of numerical value in array index. jonas.thornvall@gmail.com - 2015-03-19 05:00 -0700
          Re: Reach a digit of numerical value in array index. John Harris <niam@jghnorth.org.uk.invalid> - 2015-03-19 16:23 +0000
            Re: Reach a digit of numerical value in array index. jonas.thornvall@gmail.com - 2015-03-19 10:43 -0700
              Re: Reach a digit of numerical value in array index. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-03-19 19:51 +0100
              Re: Reach a digit of numerical value in array index. John Harris <niam@jghnorth.org.uk.invalid> - 2015-03-22 11:20 +0000
                Re: Reach a digit of numerical value in array index. jonas.thornvall@gmail.com - 2015-03-22 08:18 -0700
        Re: Reach a digit of numerical value in array index. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-03-19 15:59 +0100
          Re: Reach a digit of numerical value in array index. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-03-19 16:13 +0100
          Re: Reach a digit of numerical value in array index. Dr J R Stockton <reply1500@merlyn.demon.co.uk.invalid> - 2015-03-20 23:50 +0000
            Re: Reach a digit of numerical value in array index. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-03-22 16:29 +0100
              Re: Reach a digit of numerical value in array index. Scott Sauyet <scott@sauyet.com> - 2015-03-22 17:36 -0400
              Re: Reach a digit of numerical value in array index. Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-03-22 21:26 -0300
                Re: Reach a digit of numerical value in array index. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-03-23 05:54 +0100

csiph-web