Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #27765 > unrolled thread
| Started by | jonas.thornvall@gmail.com |
|---|---|
| First post | 2015-05-19 23:59 -0700 |
| Last post | 2015-05-20 15:12 +0200 |
| Articles | 19 — 8 participants |
Back to article view | Back to comp.lang.javascript
Merge indexes.. jonas.thornvall@gmail.com - 2015-05-19 23:59 -0700
Re: Merge indexes.. jonas.thornvall@gmail.com - 2015-05-20 01:20 -0700
Re: Merge indexes.. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-20 11:42 +0100
Re: Merge indexes.. jonas.thornvall@gmail.com - 2015-05-20 06:16 -0700
Re: Merge indexes.. John Harris <niam@jghnorth.org.uk.invalid> - 2015-05-20 14:21 +0100
Re: Merge indexes.. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-20 15:32 +0200
Re: Merge indexes.. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-20 15:52 +0200
Re: Merge indexes.. jonas.thornvall@gmail.com - 2015-05-20 08:23 -0700
Re: Merge indexes.. jonas.thornvall@gmail.com - 2015-05-21 05:51 -0700
Re: Merge indexes.. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-21 15:44 +0200
Re: Merge indexes.. jonas.thornvall@gmail.com - 2015-05-21 07:24 -0700
Re: Merge indexes.. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-21 15:52 +0100
Re: Merge indexes.. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-23 09:40 +0200
Re: Merge indexes.. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-23 11:54 +0200
Re: Merge indexes.. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-21 22:49 +0200
Re: Merge indexes.. Andrew Poulos <ap_prog@hotmail.com> - 2015-05-20 20:55 +1000
Re: Merge indexes.. "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-05-20 04:50 -0700
Re: Merge indexes.. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-20 14:32 +0200
Re: Merge indexes.. "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-20 15:12 +0200
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2015-05-19 23:59 -0700 |
| Subject | Merge indexes.. |
| Message-ID | <143762f6-417f-4f3f-82d5-272939e581d9@googlegroups.com> |
I need to merge integers at indexes within an array into an integer? [7,9,8] = 798 No join i need an integer value. How?
[toc] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2015-05-20 01:20 -0700 |
| Message-ID | <e1b4d9fe-2a97-493f-8d32-9995dc969ac2@googlegroups.com> |
| In reply to | #27765 |
Den onsdag 20 maj 2015 kl. 08:59:15 UTC+2 skrev jonas.t...@gmail.com:
> I need to merge integers at indexes within an array into an integer?
> [7,9,8] = 798
>
> No join i need an integer value.
>
> How?
Sorry i was thinking wrong should be 897, i have one way todo it. But i was thinking it should be possible to do with just concatenations rather than arithmetic?
<script>
function merge(){
for (i=0;i<myArr.length;i++){
myInt=(myArr[i]*x)+myInt;
x=x*10;
}
}
myArr =[7,9,8]
myInt=0;
x=1;
merge();
document.write(myInt);
</script>
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2015-05-20 11:42 +0100 |
| Message-ID | <87h9r7o7gw.fsf@bsb.me.uk> |
| In reply to | #27766 |
jonas.thornvall@gmail.com writes:
> Den onsdag 20 maj 2015 kl. 08:59:15 UTC+2 skrev jonas.t...@gmail.com:
>> I need to merge integers at indexes within an array into an integer?
>> [7,9,8] = 798
>>
>> No join i need an integer value.
>>
>> How?
>
> Sorry i was thinking wrong should be 897, i have one way todo it. But
> i was thinking it should be possible to do with just concatenations
> rather than arithmetic?
That's because you are still not clear about the distinction between a
number and its representation. If you have Number values (that's an
ECMAScrip type) then arithmetic is the correct way to produce new
numbers like this.
> <script>
> function merge(){
> for (i=0;i<myArr.length;i++){
> myInt=(myArr[i]*x)+myInt;
> x=x*10;
> }
> }
> myArr =[7,9,8]
> myInt=0;
> x=1;
> merge();
> document.write(myInt);
> </script>
Don't make you code worse by adding yet more function that communicate
via globals. This operation is a self-contained function of the array.
Pass the array as a parameter and return the result from the function.
--
Ben.
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2015-05-20 06:16 -0700 |
| Message-ID | <20169d03-e566-4748-ada3-40bdfb572916@googlegroups.com> |
| In reply to | #27767 |
Den onsdag 20 maj 2015 kl. 12:43:00 UTC+2 skrev Ben Bacarisse:
> jonas.thornvall@gmail.com writes:
>
> > Den onsdag 20 maj 2015 kl. 08:59:15 UTC+2 skrev jonas.t...@gmail.com:
> >> I need to merge integers at indexes within an array into an integer?
> >> [7,9,8] = 798
> >>
> >> No join i need an integer value.
> >>
> >> How?
> >
> > Sorry i was thinking wrong should be 897, i have one way todo it. But
> > i was thinking it should be possible to do with just concatenations
> > rather than arithmetic?
>
> That's because you are still not clear about the distinction between a
> number and its representation. If you have Number values (that's an
> ECMAScrip type) then arithmetic is the correct way to produce new
> numbers like this.
>
> > <script>
> > function merge(){
> > for (i=0;i<myArr.length;i++){
> > myInt=(myArr[i]*x)+myInt;
> > x=x*10;
> > }
> > }
> > myArr =[7,9,8]
> > myInt=0;
> > x=1;
> > merge();
> > document.write(myInt);
> > </script>
>
> Don't make you code worse by adding yet more function that communicate
> via globals. This operation is a self-contained function of the array.
> Pass the array as a parameter and return the result from the function.
>
> --
> Ben.
It was actually just a draw here is the one in script.
"I got it to work see next post, do both arithmetic on unsigned pairs, *arithmetic and conversion in anybase* see new post.
Now i can change the digit add within conversion to either a division or a search, have not decided which. It should make a big difference converting very big numbers.
/* MERGE THE INTEGER INDEXES OF AN ARRAY INTO ONE INTEGER */
function mergeArr(myArr)
{
myInt = 0;
x = 1;
for (i = 0; i < myArr.length; i ++ )
{
myInt = (myArr[i] * x) + myInt;
x = x * 10;
}
return myInt;
}
[toc] | [prev] | [next] | [standalone]
| From | John Harris <niam@jghnorth.org.uk.invalid> |
|---|---|
| Date | 2015-05-20 14:21 +0100 |
| Message-ID | <lh2pla9u4416cnr1pa98d169rpv9g9csdd@4ax.com> |
| In reply to | #27767 |
On Wed, 20 May 2015 11:42:55 +0100, Ben Bacarisse
<ben.usenet@bsb.me.uk> wrote:
>jonas.thornvall@gmail.com writes:
>
<snip>
>> <script>
>> function merge(){
>> for (i=0;i<myArr.length;i++){
>> myInt=(myArr[i]*x)+myInt;
>> x=x*10;
>> }
>> }
>> myArr =[7,9,8]
>> myInt=0;
>> x=1;
>> merge();
>> document.write(myInt);
>> </script>
>
>Don't make you code worse by adding yet more function that communicate
>via globals. This operation is a self-contained function of the array.
>Pass the array as a parameter and return the result from the function.
Even better, pass the base, x, as a parameter as well.
John
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2015-05-20 15:32 +0200 |
| Message-ID | <3972519.ny49QEeFJO@PointedEars.de> |
| In reply to | #27775 |
John Harris wrote:
> […] Ben Bacarisse […] wrote:
>> jonas.thornvall@gmail.com writes:
>>> <script>
>>> function merge(){
>>> for (i=0;i<myArr.length;i++){
>>> myInt=(myArr[i]*x)+myInt;
>>> x=x*10;
>>> }
>>> }
>>> myArr =[7,9,8]
>>> myInt=0;
>>> x=1;
>>> merge();
>>> document.write(myInt);
>>> </script>
>>
>>Don't make you code worse by adding yet more function that communicate
>>via globals. This operation is a self-contained function of the array.
>>Pass the array as a parameter and return the result from the function.
>
> Even better, pass the base, x, as a parameter as well.
And for bases from 2 to 36, just return parseInt(a.join(""), base), with
both “a” and “base” being formal parameters of merge(). No need to reinvent
Wheel 0.1:
<http://ecma-international.org/ecma-262/5.1/#sec-15.1.2.2>
Finally, make merge() the valueOf() method of your own object type, so that
“a” and maybe even “base” can be replaced by references to properties of the
instance.
--
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.
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2015-05-20 15:52 +0200 |
| Message-ID | <1741822.HK0jiq3ONr@PointedEars.de> |
| In reply to | #27776 |
Thomas 'PointedEars' Lahn wrote:
> John Harris wrote:
>> […] Ben Bacarisse […] wrote:
>>> jonas.thornvall@gmail.com writes:
>>>> <script>
>>>> function merge(){
>>>> for (i=0;i<myArr.length;i++){
>>>> myInt=(myArr[i]*x)+myInt;
>>>> x=x*10;
>>>> }
>>>> }
>>>> myArr =[7,9,8]
>>>> myInt=0;
>>>> x=1;
>>>> merge();
>>>> document.write(myInt);
>>>> </script>
>>>
>>>Don't make you code worse by adding yet more function that communicate
>>>via globals. This operation is a self-contained function of the array.
>>>Pass the array as a parameter and return the result from the function.
>>
>> Even better, pass the base, x, as a parameter as well.
>
> And for bases from 2 to 36, just return parseInt(a.join(""), base), with
> both “a” and “base” being formal parameters of merge(). No need to
> reinvent Wheel 0.1:
>
> <http://ecma-international.org/ecma-262/5.1/#sec-15.1.2.2>
This optimization works only if the elements of the array are the digits in
the other base (e.g., strings of length 1 if necessary), not the decimal
digit-values. So it definitely works only for bases 2 to 10 where the
string representation of each digit always has length 1 (no matter whether
it is stored as a string or a number).
--
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.
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2015-05-20 08:23 -0700 |
| Message-ID | <a01d8843-ae44-439a-aead-bd5c17708fb7@googlegroups.com> |
| In reply to | #27778 |
Den onsdag 20 maj 2015 kl. 15:54:47 UTC+2 skrev Thomas 'PointedEars' Lahn:
> Thomas 'PointedEars' Lahn wrote:
>
> > John Harris wrote:
> >> [...] Ben Bacarisse [...] wrote:
> >>> jonas.thornvall@gmail.com writes:
> >>>> <script>
> >>>> function merge(){
> >>>> for (i=0;i<myArr.length;i++){
> >>>> myInt=(myArr[i]*x)+myInt;
> >>>> x=x*10;
> >>>> }
> >>>> }
> >>>> myArr =[7,9,8]
> >>>> myInt=0;
> >>>> x=1;
> >>>> merge();
> >>>> document.write(myInt);
> >>>> </script>
> >>>
> >>>Don't make you code worse by adding yet more function that communicate
> >>>via globals. This operation is a self-contained function of the array.
> >>>Pass the array as a parameter and return the result from the function.
> >>
> >> Even better, pass the base, x, as a parameter as well.
> >
> > And for bases from 2 to 36, just return parseInt(a.join(""), base), with
> > both "a" and "base" being formal parameters of merge(). No need to
> > reinvent Wheel 0.1:
> >
> > <http://ecma-international.org/ecma-262/5.1/#sec-15.1.2.2>
>
> This optimization works only if the elements of the array are the digits in
> the other base (e.g., strings of length 1 if necessary), not the decimal
> digit-values. So it definitely works only for bases 2 to 10 where the
> string representation of each digit always has length 1 (no matter whether
> it is stored as a string or a number).
>
> --
> 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.
Well it turn out in my program if base < 11 i do not need todo anything array is correct only merge for base > 10
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2015-05-21 05:51 -0700 |
| Message-ID | <d739df81-d7fa-44cf-b095-b316991256c4@googlegroups.com> |
| In reply to | #27778 |
Den onsdag 20 maj 2015 kl. 15:54:47 UTC+2 skrev Thomas 'PointedEars' Lahn:
> Thomas 'PointedEars' Lahn wrote:
>
> > John Harris wrote:
> >> [...] Ben Bacarisse [...] wrote:
> >>> jonas.thornvall@gmail.com writes:
> >>>> <script>
> >>>> function merge(){
> >>>> for (i=0;i<myArr.length;i++){
> >>>> myInt=(myArr[i]*x)+myInt;
> >>>> x=x*10;
> >>>> }
> >>>> }
> >>>> myArr =[7,9,8]
> >>>> myInt=0;
> >>>> x=1;
> >>>> merge();
> >>>> document.write(myInt);
> >>>> </script>
> >>>
> >>>Don't make you code worse by adding yet more function that communicate
> >>>via globals. This operation is a self-contained function of the array.
> >>>Pass the array as a parameter and return the result from the function.
> >>
> >> Even better, pass the base, x, as a parameter as well.
> >
> > And for bases from 2 to 36, just return parseInt(a.join(""), base), with
> > both "a" and "base" being formal parameters of merge(). No need to
> > reinvent Wheel 0.1:
> >
> > <http://ecma-international.org/ecma-262/5.1/#sec-15.1.2.2>
>
> This optimization works only if the elements of the array are the digits in
> the other base (e.g., strings of length 1 if necessary), not the decimal
> digit-values. So it definitely works only for bases 2 to 10 where the
> string representation of each digit always has length 1 (no matter whether
> it is stored as a string or a number).
>
> --
> 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.
I have a question Thomas. Why doesn't join work on any object?
Does the program that do the readout have to be aware about what is read out, and if so why can't there be a join(myArr,int) or join(myArr,32b).
I beleive there is many occasions where people actually want to merge integers at indexes in array. But of course overflow is a problem.
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2015-05-21 15:44 +0200 |
| Message-ID | <XnsA4A1A010E10E9eejj99@194.109.133.246> |
| In reply to | #27783 |
jonas.thornvall@gmail.com wrote on 21 mei 2015 in comp.lang.javascript: > I have a question Thomas. > Why doesn't join work on any object? Because Javascript join() is made to join arrays into a string. > Does the program that do the readout What programme? What readout? > have to be aware about what is read out, Do you mean "Javascript" by "the programme"? Are programmes ever aware yet? > and if so quod non. > why can't there be a join(myArr,int) or join(myArr,32b). because Javascript is not designed that way. > I beleive believe[!] [= just think it is without good ground] > there is many **are** many occasions[plural] > occasions where people actually want > to merge integers at indexes in array. integers are values. indexes are POINTERS to members of an array. Methinks merging indexes **at** values is impossible, but sometimes people believe that other people want the impossible. You can **merge** members of an array to a string, having a boundary string inbetween, but you cannot merge members **at their pointers**. and certainly ont values at their pointers. As usual you are using the wrong words, making mockery of your Q. > But of course overflow is a problem. No, not "of course", don't say that, as it only shows you cannot explain. Is there an overflow of indexes at such value? -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2015-05-21 07:24 -0700 |
| Message-ID | <dc2b8fc8-f59a-4fdd-8d43-5c9c5c768f1d@googlegroups.com> |
| In reply to | #27785 |
Den torsdag 21 maj 2015 kl. 15:44:08 UTC+2 skrev Evertjan.: > jonas.thornvall@gmail.com wrote on 21 mei 2015 in comp.lang.javascript: > > > I have a question Thomas. > > Why doesn't join work on any object? > > Because Javascript join() is made to join arrays into a string. > > > Does the program that do the readout > > What programme? > What readout? > > > have to be aware about what is read out, > > Do you mean "Javascript" by "the programme"? > > Are programmes ever aware yet? > > > and if so > > quod non. > > > why can't there be a join(myArr,int) or join(myArr,32b). > > because Javascript is not designed that way. > > > I beleive > > believe[!] [= just think it is without good ground] > > > there is many > > **are** many occasions[plural] > > > occasions where people actually want > > to merge integers at indexes in array. > > integers are values. > indexes are POINTERS to members of an array. > > Methinks merging indexes **at** values is impossible, > but sometimes people believe that other people want the impossible. > > You can **merge** members of an array to a string, > having a boundary string inbetween, > but you cannot merge members **at their pointers**. > and certainly ont values at their pointers. > > As usual you are using the wrong words, making mockery of your Q. > > > But of course overflow is a problem. > > No, not "of course", don't say that, > as it only shows you cannot explain. > > Is there an overflow of indexes at such value? > > -- > Evertjan. > The Netherlands. > (Please change the x'es to dots in my emailaddress) Well Evertjan if your array hold and concatenate/merge more than 10 digits, an integer won't hold them and you have problem with overflow?
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2015-05-21 15:52 +0100 |
| Message-ID | <87a8wym199.fsf@bsb.me.uk> |
| In reply to | #27787 |
jonas.thornvall@gmail.com writes: <snip> > Well Evertjan if your array hold and concatenate/merge more than 10 > digits, an integer won't hold them and you have problem with overflow? Integers are unbounded and don't overflow. ECMAScript uses floating point to represent numbers and can store exact integers up to 9007199254740992 which is more than 10 digits. Arrays of digits of any length can be exactly concatenating in ECMAScript provided they have enough leading zeros. -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2015-05-23 09:40 +0200 |
| Message-ID | <5700359.JzBnhicJbn@PointedEars.de> |
| In reply to | #27788 |
Ben Bacarisse wrote: > jonas.thornvall@gmail.com writes: > <snip> >> Well Evertjan if your array hold and concatenate/merge more than 10 >> digits, an integer won't hold them and you have problem with overflow? > > Integers are unbounded and don't overflow. ECMAScript uses floating > point to represent numbers and can store exact integers up to > 9007199254740992 which is more than 10 digits. Arrays of digits of any > length can be exactly concatenating in ECMAScript provided they have > enough leading zeros. What do leading zeroes have to do with it? -- 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.
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2015-05-23 11:54 +0200 |
| Message-ID | <XnsA4A3792152278eejj99@194.109.133.246> |
| In reply to | #27844 |
Thomas 'PointedEars' Lahn <PointedEars@web.de> wrote on 23 mei 2015 in comp.lang.javascript: > Ben Bacarisse wrote: > >> jonas.thornvall@gmail.com writes: >> <snip> >>> Well Evertjan if your array hold and concatenate/merge more than 10 >>> digits, an integer won't hold them and you have problem with overflow? >> >> Integers are unbounded and don't overflow. ECMAScript uses floating >> point to represent numbers and can store exact integers up to >> 9007199254740992 which is more than 10 digits. Arrays of digits of any >> length can be exactly concatenating in ECMAScript provided they have >> enough leading zeros. > > What do leading zeroes have to do with it? Indeed you can get get any length strings to comply if they have enough leading zeros, testing: alert( +"000000000000000000000000000009007199254740992" ); Yes!!!! Are we still being serious? -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2015-05-21 22:49 +0200 |
| Message-ID | <XnsA4A1E83C6B860eejj99@194.109.133.246> |
| In reply to | #27787 |
jonas.thornvall@gmail.com wrote on 21 mei 2015 in comp.lang.javascript: Why don't you answer any of my Qs? They are ment to help you understand better. > Well Evertjan if your array hold and concatenate/merge more than 10 > digits, an integer won't hold them and you have problem with overflow? It is "Your" array, not mine. "I" have no problems with that. "I" would not call it "overflow". An integer is just a special value, and values do not hold anything, containers do. Containers are named variables of type floating point, array, string or perhaps object. You are mixing the idea of representation with the idea of value, and make it needlessly difficult for yourelf. since Javascript strings have 16 bit characters, you should be able to join arrays with member values upto 2^16 in a string. Is that string readable? No, but that is not the point, or is it? If it is, you are mixing the idea of visual[!] representation with the idea of value. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Andrew Poulos <ap_prog@hotmail.com> |
|---|---|
| Date | 2015-05-20 20:55 +1000 |
| Message-ID | <4uydnWkQTM6a9cHInZ2dnUVZ7o2dnZ2d@westnet.com.au> |
| In reply to | #27765 |
On 20/05/2015 4:59 PM, jonas.thornvall@gmail.com wrote:
> I need to merge integers at indexes within an array into an integer?
> [7,9,8] = 798
>
> No join i need an integer value.
What about
var a = [7, 9, 8],
m = parseInt( a.join(''), 10);
?
Andrew Poulos
[toc] | [prev] | [next] | [standalone]
| From | "Michael Haufe (TNO)" <tno@thenewobjective.com> |
|---|---|
| Date | 2015-05-20 04:50 -0700 |
| Message-ID | <fbaad499-c78c-4360-940e-0adfe24875ba@googlegroups.com> |
| In reply to | #27768 |
On Wednesday, May 20, 2015 at 5:55:13 AM UTC-5, Andrew Poulos wrote:
> What about
>
> var a = [7, 9, 8],
> m = parseInt( a.join(''), 10);
m = Number(a.join(''));
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2015-05-20 14:32 +0200 |
| Message-ID | <3151338.5aQO04xTsX@PointedEars.de> |
| In reply to | #27770 |
Michael Haufe (TNO) wrote:
> On Wednesday, May 20, 2015 at 5:55:13 AM UTC-5, Andrew Poulos wrote:
>> What about
>>
>> var a = [7, 9, 8],
>> m = parseInt( a.join(''), 10);
>
> m = Number(a.join(''));
[0, 1, 2]
--
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.
[toc] | [prev] | [next] | [standalone]
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Date | 2015-05-20 15:12 +0200 |
| Message-ID | <mji172$4sv$1@solani.org> |
| In reply to | #27771 |
Thomas 'PointedEars' Lahn wrote:
> Michael Haufe (TNO) wrote:
>
>> On Wednesday, May 20, 2015 at 5:55:13 AM UTC-5, Andrew Poulos wrote:
>>> What about
>>>
>>> var a = [7, 9, 8],
>>> m = parseInt( a.join(''), 10);
>>
>> m = Number(a.join(''));
>
> [0, 1, 2]
According to ES 5.1, section 9.3[1]:
| A StringNumericLiteral that is decimal may have any number of leading
| 0 digits.
[1] <http://ecma-international.org/ecma-262/5.1/#sec-9.3>
--
Christoph M. Becker
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web