Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #27101
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Reach a digit of numerical value in array index. |
| Date | 2015-03-22 16:29 +0100 |
| Organization | PointedEars Software (PES) |
| Message-ID | <8127222.NEJAP2j12Q@PointedEars.de> (permalink) |
| References | (1 earlier) <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> |
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
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