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


Groups > comp.lang.javascript > #23508 > unrolled thread

arr.push(obj);

Started byjonas.thornvall@gmail.com
First post2014-03-10 17:38 -0700
Last post2014-03-11 15:19 +0000
Articles 20 on this page of 46 — 7 participants

Back to article view | Back to comp.lang.javascript


Contents

  arr.push(obj); jonas.thornvall@gmail.com - 2014-03-10 17:38 -0700
    Re: arr.push(obj); jonas.thornvall@gmail.com - 2014-03-10 20:19 -0700
      Re: arr.push(obj); jonas.thornvall@gmail.com - 2014-03-10 20:28 -0700
        Re: arr.push(obj); jonas.thornvall@gmail.com - 2014-03-10 21:19 -0700
          Re: arr.push(obj); Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2014-03-11 06:59 -0300
            Re: arr.push(obj); Christoph Michael Becker <cmbecker69@arcor.de> - 2014-03-11 16:02 +0100
              Re: arr.push(obj); Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-03-11 16:22 +0000
              Re: arr.push(obj); Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2014-03-11 13:32 -0300
    Re: arr.push(obj); "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-03-11 10:21 +0100
      Re: arr.push(obj); jonas.thornvall@gmail.com - 2014-03-11 03:53 -0700
        Re: arr.push(obj); "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-03-11 14:03 +0100
          Re: arr.push(obj); jonas.thornvall@gmail.com - 2014-03-11 07:45 -0700
            Re: arr.push(obj); "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-03-11 16:24 +0100
              Re: arr.push(obj); jonas.thornvall@gmail.com - 2014-03-11 10:40 -0700
                Re: arr.push(obj); jonas.thornvall@gmail.com - 2014-03-11 10:51 -0700
                  Re: arr.push(obj); Christoph Michael Becker <cmbecker69@arcor.de> - 2014-03-11 19:23 +0100
                    Re: arr.push(obj); jonas.thornvall@gmail.com - 2014-03-11 15:33 -0700
                      Re: arr.push(obj); "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-03-12 00:37 +0100
                        Re: arr.push(obj); jonas.thornvall@gmail.com - 2014-03-11 16:46 -0700
                          Re: arr.push(obj); "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-03-12 01:05 +0100
                          Re: arr.push(obj); Christoph Michael Becker <cmbecker69@arcor.de> - 2014-03-12 01:40 +0100
                      Re: arr.push(obj); Christoph Michael Becker <cmbecker69@arcor.de> - 2014-03-12 00:48 +0100
                    Re: arr.push(obj); jonas.thornvall@gmail.com - 2014-03-11 15:43 -0700
                      Re: arr.push(obj); jonas.thornvall@gmail.com - 2014-03-11 16:18 -0700
                        Re: arr.push(obj); "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-03-12 00:39 +0100
                          Re: arr.push(obj); Christoph Michael Becker <cmbecker69@arcor.de> - 2014-03-12 00:52 +0100
                      Re: arr.push(obj); Christoph Michael Becker <cmbecker69@arcor.de> - 2014-03-12 00:49 +0100
                        Re: arr.push(obj); jonas.thornvall@gmail.com - 2014-03-11 17:16 -0700
                          Re: arr.push(obj); Christoph Michael Becker <cmbecker69@arcor.de> - 2014-03-12 02:07 +0100
                            Re: arr.push(obj); jonas.thornvall@gmail.com - 2014-03-11 18:13 -0700
                              Re: arr.push(obj); Christoph Michael Becker <cmbecker69@arcor.de> - 2014-03-13 02:25 +0100
                                Re: arr.push(obj); Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-03-13 11:03 +0100
                            Re: arr.push(obj); jonas.thornvall@gmail.com - 2014-03-12 07:46 -0700
                        Re: arr.push(obj); Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-03-12 01:27 +0100
                          Re: arr.push(obj); Christoph Michael Becker <cmbecker69@arcor.de> - 2014-03-12 01:44 +0100
            Re: arr.push(obj); Christoph Michael Becker <cmbecker69@arcor.de> - 2014-03-11 16:26 +0100
              Re: arr.push(obj); Carlos Pedro <carlospedr@gmail.com> - 2014-03-11 09:21 -0700
              Re: arr.push(obj); Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-03-11 18:01 +0100
                Re: arr.push(obj); Christoph Michael Becker <cmbecker69@arcor.de> - 2014-03-11 19:15 +0100
                  Re: arr.push(obj); Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-03-11 20:32 +0100
                    Re: arr.push(obj); Christoph Michael Becker <cmbecker69@arcor.de> - 2014-03-12 01:01 +0100
                      Re: arr.push(obj); Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-03-12 04:08 +0100
                        Re: arr.push(obj); Christoph Michael Becker <cmbecker69@arcor.de> - 2014-03-12 18:00 +0100
    Re: arr.push(obj); Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2014-03-11 06:24 -0300
      Re: arr.push(obj); jonas.thornvall@gmail.com - 2014-03-11 03:47 -0700
        Re: arr.push(obj); Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-03-11 15:19 +0000

Page 2 of 3 — ← Prev page 1 [2] 3  Next page →


#23555

FromChristoph Michael Becker <cmbecker69@arcor.de>
Date2014-03-12 01:40 +0100
Message-ID<531facf7$0$6667$9b4e6d93@newsspool2.arcor-online.net>
In reply to#23544
jonas.thornvall@gmail.com wrote:

> What object, isn't it an array?

In ECMAScript Arrays are Objects, see
<http://www.ecma-international.org/ecma-262/5.1/#sec-15.4>.

-- 
Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#23545

FromChristoph Michael Becker <cmbecker69@arcor.de>
Date2014-03-12 00:48 +0100
Message-ID<531fa0e2$0$6667$9b4e6d93@newsspool2.arcor-online.net>
In reply to#23538
jonas.thornvall@gmail.com wrote:

> Honestly i have no idea what you talk about.
> You honestly try to tell me that the code does not deal with indexes?
> <script type="text/javascript">
> var arr=[];
> for (i=10;i>=-20;i--) {arr[i]=i;}
> YOU TELL ME THAT -22 NOT AN INDEX HERE?arr[-22]=-22;
> for (i=10;i>=-22;i--) {document.write(arr[i],",");}
> </script> 
> I must say that programming languages just get weirder you call it a property?

Well, ECMAScript is indeed somewhat special wrt. to arrays.  Consider a
simple object assigned to the variable a:

  var a = {
    count : i,
    fcolor : 'black'
  };

To access the count property, you'll write

  a.count

but you can equally well use the following expression:

  a["count"]

In short: the bracket notation is meant for accessing properties of objects.

An array is a somewhat special kind of object, where properties with
names that resemble non-negative integer numbers are called indexes and
treated specially by several of the built-in methods.  Consider:

  var a = []; // btw, that's syntactic sugar for new Array()
  a[0] = "foo";
  a["1"] = "bar"; // using a string as index
  console.log(a); // => ["foo", "bar"]

Theoretically, it could be even possible to use the dot notation to
access these index properties, but that is defined as syntactic error:

  a.0 // => syntax error

FWIW: as hinted in another sub-thread you could even use an object as
some kind of array:

  var a = {};
  a[0] = "foo";
  a[1] = "bar";
  for (var i = 0; i <= 1; ++i) {
    console.log(a[i]);
  } // => foo bar

-- 
Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#23540

Fromjonas.thornvall@gmail.com
Date2014-03-11 15:43 -0700
Message-ID<c8b312b8-eef9-4f65-abf2-c2725a2d4dc9@googlegroups.com>
In reply to#23536
Den tisdagen den 11:e mars 2014 kl. 19:23:10 UTC+1 skrev Christoph Michael Becker:
> jonas.thornvall@gmail.com wrote:
> 
> 
> 
> > I do not need length or any attribute of array it implicit in my
> 
> > code, but i do need objects or multidimensional arrays that can store
> 
> > strings, ***at negative indexes.***
> 
> > 
> 
> > I showed you that the array will store values at negative indexes.
> 
> 
> 
> No.  You have shown that an array can store values in properties whose
> 
> name resembles a negative number.
> 
> 
> 
> >                                                                     So
> 
> > my question remains can i set also objects not only values at the
> 
> > negative indexes of an array.
> 
> 
> 
> As there are no negative indexes[1], you can't.  However, you can store
> 
> arbitrary values (for instance, object references) in properties.
> 
> 
> 
> > And how do i achieve that.
> 
> 
> 
>   a[-1] = {};

I try to get the gist of what you saying but for me it is all very confusing.
Do you mean something like this?

var arr = new Array();
for (var i = -500; i <= +500; i ++ )
{
arr[i] =
   {
      count : i,
      fcolor : 'black',
      rheight : 100,
      rwidth : 100,
      rcolor : 'white'
   }
} 

Best regards JT


> 
> 
> 
> [1] <http://www.ecma-international.org/ecma-262/5.1/#sec-15.4>
> 
> 
> 
> -- 
> 
> Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#23541

Fromjonas.thornvall@gmail.com
Date2014-03-11 16:18 -0700
Message-ID<31b53a30-29d6-415f-b4b1-dc2254f05f9b@googlegroups.com>
In reply to#23540
Den tisdagen den 11:e mars 2014 kl. 23:43:31 UTC+1 skrev jonas.t...@gmail.com:
> Den tisdagen den 11:e mars 2014 kl. 19:23:10 UTC+1 skrev Christoph Michael Becker:
> 
> > jonas.thornvall@gmail.com wrote:
> 
> > 
> 
> > 
> 
> > 
> 
> > > I do not need length or any attribute of array it implicit in my
> 
> > 
> 
> > > code, but i do need objects or multidimensional arrays that can store
> 
> > 
> 
> > > strings, ***at negative indexes.***
> 
> > 
> 
> > > 
> 
> > 
> 
> > > I showed you that the array will store values at negative indexes.
> 
> > 
> 
> > 
> 
> > 
> 
> > No.  You have shown that an array can store values in properties whose
> 
> > 
> 
> > name resembles a negative number.
> 
> > 
> 
> > 
> 
> > 
> 
> > >                                                                     So
> 
> > 
> 
> > > my question remains can i set also objects not only values at the
> 
> > 
> 
> > > negative indexes of an array.
> 
> > 
> 
> > 
> 
> > 
> 
> > As there are no negative indexes[1], you can't.  However, you can store
> 
> > 
> 
> > arbitrary values (for instance, object references) in properties.
> 
> > 
> 
> > 
> 
> > 
> 
> > > And how do i achieve that.
> 
> > 
> 
> > 
> 
> > 
> 
> >   a[-1] = {};
> 
> 
> 
> I try to get the gist of what you saying but for me it is all very confusing.
> 
> Do you mean something like this?
> 
> 
> 
> var arr = new Array();
> 
> for (var i = -500; i <= +500; i ++ )
> 
> {
> 
> arr[i] =
> 
>    {
> 
>       count : i,
> 
>       fcolor : 'black',
> 
>       rheight : 100,
> 
>       rwidth : 100,
> 
>       rcolor : 'white'
> 
>    }
> 
> } 
> 
> 
> 
> Best regards JT
> 
> 
> 
> 
> 
> > 
> 
> > 
> 
> > 
> 
> > [1] <http://www.ecma-international.org/ecma-262/5.1/#sec-15.4>
> 
> > 
> 
> > 
> 
> > 
> 
> > -- 
> 
> > 
> 
> > Christoph M. Becker

Is this the javascript version of multidimensional array?

[toc] | [prev] | [next] | [standalone]


#23543

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2014-03-12 00:39 +0100
Message-ID<XnsA2EE6AEF3917eejj99@194.109.133.133>
In reply to#23541
jonas.thornvall@gmail.com wrote on 12 mrt 2014 in comp.lang.javascript:

> Is this the javascript version of multidimensional array?

Javascript has NO multidimensional arrays.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#23548

FromChristoph Michael Becker <cmbecker69@arcor.de>
Date2014-03-12 00:52 +0100
Message-ID<531fa1d1$0$6671$9b4e6d93@newsspool2.arcor-online.net>
In reply to#23543
Evertjan. wrote:

> jonas.thornvall@gmail.com wrote on 12 mrt 2014 in comp.lang.javascript:
> 
>> Is this the javascript version of multidimensional array?
> 
> Javascript has NO multidimensional arrays.

ACK.  Besides Jonas' code builds an array of objects, and not an array
of arrays, which might be regarded as counterpart of multidimensional
arrays.

-- 
Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#23547

FromChristoph Michael Becker <cmbecker69@arcor.de>
Date2014-03-12 00:49 +0100
Message-ID<531fa123$0$6667$9b4e6d93@newsspool2.arcor-online.net>
In reply to#23540
jonas.thornvall@gmail.com wrote:

> I try to get the gist of what you saying but for me it is all very confusing.
> Do you mean something like this?
> 
> var arr = new Array();
> for (var i = -500; i <= +500; i ++ )
> {
> arr[i] =
>    {
>       count : i,
>       fcolor : 'black',
>       rheight : 100,
>       rwidth : 100,
>       rcolor : 'white'
>    }
> } 

Yes.  If you prefer, you can use another variable to store the object
first, e.g.:

  {
    var obj = {...};
    arr[i] = obj;
  }

-- 
Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#23552

Fromjonas.thornvall@gmail.com
Date2014-03-11 17:16 -0700
Message-ID<73edf0c2-8d5d-4224-a654-00673bcfbfff@googlegroups.com>
In reply to#23547
Den onsdagen den 12:e mars 2014 kl. 00:49:59 UTC+1 skrev Christoph Michael Becker:
> jonas.thornvall@gmail.com wrote:
> 
> 
> 
> > I try to get the gist of what you saying but for me it is all very confusing.
> 
> > Do you mean something like this?
> 
> > 
> 
> > var arr = new Array();
> 
> > for (var i = -500; i <= +500; i ++ )
> 
> > {
> 
> > arr[i] =
> 
> >    {
> 
> >       count : i,
> 
> >       fcolor : 'black',
> 
> >       rheight : 100,
> 
> >       rwidth : 100,
> 
> >       rcolor : 'white'
> 
> >    }
> 
> > } 
> 
> 
> 
> Yes.  If you prefer, you can use another variable to store the object
> 
> first, e.g.:
> 
> 
> 
>   {
> 
>     var obj = {...};
> 
>     arr[i] = obj;
> 
>   }
> 
> 
> 
> -- 
> 
> Christoph M. Becker

Thank you i am greatful Christoph tomorrow i will try to implement the approach in my code.
I wish you javascript expert could be a little more explicit in your example, when you just write  arr[i] ={} i am not really sure what you expect me to put between the brackets i thought the semicolon separated name values was inherent to objects, you could copied from my example code and i would had understand.

One last question do i reach the element as with the object
ctx.fillStyle = arr[i].rcolor;

Thanks again Christoph

[toc] | [prev] | [next] | [standalone]


#23556

FromChristoph Michael Becker <cmbecker69@arcor.de>
Date2014-03-12 02:07 +0100
Message-ID<531fb346$0$6666$9b4e6d93@newsspool2.arcor-online.net>
In reply to#23552
jonas.thornvall@gmail.com wrote:

> Thank you i am greatful Christoph tomorrow i will try to implement
> the approach in my code.

This code was not meant as suggestion, but rather to explain, that there
is not *so* much special about arrays in ECMAScript.

>                           I wish you javascript expert could be a
> little more explicit in your example, when you just write  arr[i] ={}
> i am not really sure what you expect me to put between the brackets i
> thought the semicolon separated name values was inherent to objects,
> you could copied from my example code and i would had understand.

The {} is an empty object literal, and was meant as such.

Copying from your code is possible, but that would require much more
time, and generally this newsgroup is not about giving fish, but rather
teaching others to fish themselves (besides discussing how to fish best).

You may consider catching up on ECMAScript; see this newsgroup's FAQ for
available and recommendable resources[1].

BTW: I'm *far* from being a JavaScript expert.

> One last question do i reach the element as with the object 
> ctx.fillStyle = arr[i].rcolor;

You can check that yourself with your browser's development tools[2],
which are really very helpful.  I suggest you learn to use them; at
least the script console, where you can type in code for immediate
evaluation in the context of the current document, and which you can use
to view debug output of console.log() and friends, which are almost
always preferable to window.alert().

[1] <http://pointedears.de/scripts/faq/cljs/#ecmascriptResources>
[2] <http://devtoolsecrets.com/>

-- 
Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#23557

Fromjonas.thornvall@gmail.com
Date2014-03-11 18:13 -0700
Message-ID<7a80bd23-da9f-4fb3-9633-98d0c8f2a7af@googlegroups.com>
In reply to#23556
Den onsdagen den 12:e mars 2014 kl. 02:07:23 UTC+1 skrev Christoph Michael Becker:
> jonas.thornvall@gmail.com wrote:
> 
> 
> 
> > Thank you i am greatful Christoph tomorrow i will try to implement
> 
> > the approach in my code.
> 
> 
> 
> This code was not meant as suggestion, but rather to explain, that there
> 
> is not *so* much special about arrays in ECMAScript.
> 
> 
> 
> >                           I wish you javascript expert could be a
> 
> > little more explicit in your example, when you just write  arr[i] ={}
> 
> > i am not really sure what you expect me to put between the brackets i
> 
> > thought the semicolon separated name values was inherent to objects,
> 
> > you could copied from my example code and i would had understand.
> 
> 
> 
> The {} is an empty object literal, and was meant as such.
> 
> 
> 
> Copying from your code is possible, but that would require much more
> 
> time, and generally this newsgroup is not about giving fish, but rather
> 
> teaching others to fish themselves (besides discussing how to fish best).
> 
> 
> 
> You may consider catching up on ECMAScript; see this newsgroup's FAQ for
> 
> available and recommendable resources[1].
> 
> 
> 
> BTW: I'm *far* from being a JavaScript expert.
> 
> 
> 
> > One last question do i reach the element as with the object 
> 
> > ctx.fillStyle = arr[i].rcolor;
> 
> 
> 
> You can check that yourself with your browser's development tools[2],
> 
> which are really very helpful.  I suggest you learn to use them; at
> 
> least the script console, where you can type in code for immediate
> 
> evaluation in the context of the current document, and which you can use
> 
> to view debug output of console.log() and friends, which are almost
> 
> always preferable to window.alert().
> 
> 
> 
> [1] <http://pointedears.de/scripts/faq/cljs/#ecmascriptResources>
> 
> [2] <http://devtoolsecrets.com/>
> 
> 
> 
> -- 
> 
> Christoph M. Becker

Thanks to you Christoph it is all working changed 2 lines of code, the other guys would have me dragged around talking about none issues for weeks. It is hard to say what they get out of it.

Your a great guy!!! 

[toc] | [prev] | [next] | [standalone]


#23583

FromChristoph Michael Becker <cmbecker69@arcor.de>
Date2014-03-13 02:25 +0100
Message-ID<532108ec$0$6666$9b4e6d93@newsspool2.arcor-online.net>
In reply to#23557
jonas.thornvall@gmail.com wrote:

> Thanks to you Christoph 

You're welcome.

>                          it is all working changed 2 lines of code,

Fine. :)

> the other guys would have me dragged around talking about none issues
> for weeks. It is hard to say what they get out of it.

Well, I don't think these are "non issues" -- they might be for your
particular problem, but surely these are issues generally.  Please keep
in mind that even though this might be regarded as "your" thread, many
others will look it up to solve their own problems, where the difference
between properties and indexes might be very relevant.

Personally, I am grateful that others have pointed out this difference,
as I was not fully aware of it before, so I was able to learn.

-- 
Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#23584

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2014-03-13 11:03 +0100
Message-ID<2310580.y00DJikEAR@PointedEars.de>
In reply to#23583
Christoph Michael Becker wrote:

> jonas.thornvall@gmail.com wrote:
>> the other guys would have me dragged around talking about none issues
>> for weeks. It is hard to say what they get out of it.
> 
> Well, I don't think these are "non issues" -- they might be for your
> particular problem, but surely these are issues generally.

ACK.

> Please keep in mind that even though this might be regarded as "your"
> thread

In which parallel universe?

> many others will look it up to solve their own problems, where the
> difference between properties and indexes might be very relevant.

ACK.
 
> Personally, I am grateful that others have pointed out this difference,
> as I was not fully aware of it before, so I was able to learn.
                                            ^^^^^^^^^^^^^^^^^^^
Which is why, among other things, “the other guys” invest their precious 
free time to read your postings, but not his (except in quotations; thanks 
for confirming the killfile entry).

<http://www.catb.org/~esr/faqs/smart-questions.html#not_losing>

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


#23571

Fromjonas.thornvall@gmail.com
Date2014-03-12 07:46 -0700
Message-ID<1a39849b-b5ee-48f7-9416-491bc4960999@googlegroups.com>
In reply to#23556
Den onsdagen den 12:e mars 2014 kl. 02:07:23 UTC+1 skrev Christoph Michael Becker:
> jonas.thornvall@gmail.com wrote:
> 
> 
> 
> > Thank you i am greatful Christoph tomorrow i will try to implement
> 
> > the approach in my code.
> 
> 
> 
> This code was not meant as suggestion, but rather to explain, that there
> 
> is not *so* much special about arrays in ECMAScript.
> 
> 
> 
> >                           I wish you javascript expert could be a
> 
> > little more explicit in your example, when you just write  arr[i] ={}
> 
> > i am not really sure what you expect me to put between the brackets i
> 
> > thought the semicolon separated name values was inherent to objects,
> 
> > you could copied from my example code and i would had understand.
> 
> 
> 
> The {} is an empty object literal, and was meant as such.
> 
> 
> 
> Copying from your code is possible, but that would require much more
> 
> time, and generally this newsgroup is not about giving fish, but rather
> 
> teaching others to fish themselves (besides discussing how to fish best).
> 
> 
> 
> You may consider catching up on ECMAScript; see this newsgroup's FAQ for
> 
> available and recommendable resources[1].
> 
> 
> 
> BTW: I'm *far* from being a JavaScript expert.
> 
> 
> 
> > One last question do i reach the element as with the object 
> 
> > ctx.fillStyle = arr[i].rcolor;
> 
> 
> 
> You can check that yourself with your browser's development tools[2],
> 
> which are really very helpful.  I suggest you learn to use them; at
> 
> least the script console, where you can type in code for immediate
> 
> evaluation in the context of the current document, and which you can use
> 
> to view debug output of console.log() and friends, which are almost
> 
> always preferable to window.alert().
> 
> 
> 
> [1] <http://pointedears.de/scripts/faq/cljs/#ecmascriptResources>
> 
> [2] <http://devtoolsecrets.com/>
> 
> 
> 
> -- 
> 
> Christoph M. Becker

Here is my script *working*, it is a toy but it says something about the natural numbers.
I will expand it with Fibonacci, cubics and interesting numbersequenses.

Feel free to comment on it.

<!DOCTYPE html>
<html>
<head>
    <meta http-Equiv="Cache-Control" Content="no-cache">
    <meta http-Equiv="Pragma" Content="no-cache">
    <meta http-Equiv="Expires" Content="0">
</head>

<body onload=first_call();>

<div id="container" style="width:2100px">

<div id="header" style="background-color:#FFA500;">
<table width=2100 border="2" bgcolor="White" ><tr><td>
<B>PRIME EXPLORER v0.82 Bugs stills here but replaced FRAMES with DIV<font size=1></B>jonas.thornvall@hotmail.com</font></td>
</tr></table>

</div>

<div id="menu" style="background-color:lightgray;height:2000px;width:140px;float:left;">

<FONT=BOLD>

<table border="2" bgcolor="grey" width=140>

<tr>

<td align=middle bgcolor="yellow">+<BR><input type="checkbox" id="pos" name="pos" onchange=recheck(); checked="yes"></td>
<td align=middle bgcolor="lightgrey">-<BR><input type="checkbox" id="neg" name="neg" onchange=recheck(); checked="no"></td>
<td align=middle bgcolor="blue">P<input id="p" type="checkbox" name="p" onchange=recheck(); checked="yes"></td>
<td align=middle bgcolor="red">Sq<input type="checkbox" name="sq" id="sq" onchange=recheck(); checked="yes"></td>
</tr>
<tr>
<td align=middle bgcolor="pink">O <BR><input type="checkbox" name="o" id="o"  onchange=recheck(); ></td>
<td align=middle bgcolor="lightblue">E <input type="checkbox" name="e" id="e" onchange=recheck(); ></td>

</tr>
</table>

<table border="2" bgcolor="yellow" width=140><tr><td>
<FORM NAME=Xdoit onSubmit="reinitiate(); return false;">
<input type=submit value="N min">
<input type="text" name="start_At" value="-144" size="4">
</FORM>
</td></tr></table>

<table border="2" bgcolor="yellow" width=140><tr><td>
<FORM NAME=Adoit onSubmit="next(); return false;">
<input type=submit value="Forw">
</FORM> </td><td>

<FORM NAME=Bdoit onSubmit="prev(); return false;">
<input type=submit value="Backw">
</FORM>
</td></tr></table>



<table border="2" bgcolor="yellow" width=140><tr><td bgcolor="green">
<FORM NAME=Edoit onSubmit="initanime(); return false;">
<input type=submit name="init_anime" value="Anim"></FORM></td>
<td bgcolor="red">
<FORM NAME=Fdoit onSubmit="stopanime(); return false;">
<input type=submit name="stop_anime" value="haltA">
</FORM>
</td></tr></table>


<table border="2" bgcolor="lightblue" width=140><tr><td>
<FORM NAME=Jdoit onSubmit="reinitiate(); return false;">
<input type=submit value="N max">
<input type="text" name="rangeN" value="400" size="6">
</FORM>
</td></tr></table>





<table border="1" bgcolor="grey" width=140><tr><td>
<FORM NAME=Cdoit onSubmit="zoomin(); return false;">
<input type=submit name="zoom_in" value="Zoom+"><P>
</FORM>
</td><td>
<FORM NAME=Ddoit onSubmit="zoomout(); return false;">
<input type=submit name="zoom_out" value="Zoom-"><P>
</FORM>
</td></tr></table>

<table border="2" bgcolor="grey" width=140<tr><td>
<FORM NAME=Zdoit onSubmit="square_size(); return false;">
<input type=submit value="SQ size">
<input type="text" name="sqsize" value="2" size="3"><br>
</FORM>
</td></tr></table>

<table border="2" bgcolor="yellow" width=140><tr><td colspan="2">
<FORM NAME=Ldoit onSubmit="offset(); return false;">
<input type=submit value="N offset Col/Row">
</td></tr><tr><td>
X-<input type="text" name="xledf" value="1" size="2"></td><td>
Y-<input type="text" name="yledf" value="0" size="2">
</FORM>
</td></tr></table>
<table border="2" bgcolor="yellow" width=140><tr><td>
<FORM NAME=xplus onSubmit="plusX(); return false;">
<input type=submit name="x_plus" value="X+">
</FORM>

</td><td>
<FORM NAME=xminus onSubmit="minusX(); return false;">
<input type=submit name="x_minus" value="X-">
</FORM>
</td></tr><tr><td>

<FORM NAME=yplus onSubmit="plusY(); return false;">
<input type=submit name="y_plus" value="Y+">
</FORM>
</td><td>

<FORM NAME=yminus onSubmit="minusY(); return false;">
<input type=submit name="y_minus" value="Y-">
</FORM>
</td></tr></table>
</div>


<div id="content" style="background-color:lightyellow;height:1900px;width:1900;float:left;">
<canvas id="myCanvas" width="1900" height="1900">Your browser does not support the HTML5 canvas tag.</canvas>


<script type="text/javascript">


//Global variables
var square = 0;
var size = 0;
var run = 0;
var back = 0;
var down = 0;
var adder = 0;
var refresh = 5;
var width = 0;
var height = 0;
var primearray = new Array();
var arr = new Array();
var start=0;
var range=0;

// HERE IS THE DRAW FUNCTIONS

function redraw()
{
   clear();
   init();
   paint_logic();
}


function clear()
{
   ctx.clearRect(0, 0, 1900, 1900);
}

function init()
{

   down = yyled;
   back = xxled;
   v_inner = 0;
   h_inner = 0;
   h_outer = 0;
   v_outer = 0;
   vcoffset = 0;
   hcoffset = 0;

   if(run = 1)numberStart = numberStart + adder;
   number = numberStart;
   h_outer = asize * (back);
   if (xxled < 0)
   {
      vcoffset = (xxled * - asize);
   }
   if (yyled < - 0)
   {
      hcoffset = (yyled * - asize);
   }
}

function paint_logic()
{
   while(number < numbRange)
   
   {
      document.Xdoit.start_At.value = numberStart;
      vertical = 0;
      v_outer = 0;
      v_inner = v_outer;
      h_inner = h_outer;
      square = 0;
      negsquare = 0;

      while(vertical < down)
      {
         if (number == 0) number ++ ;

         paint_out();
         v_inner = v_inner + asize;
         vertical ++ ;
         number ++ ;
      }
      down ++ ;
      horisontal = 0;
      h_inner = h_outer;

      while(horisontal < back)
      {
         if (number == 0) number ++ ;
         paint_out();
         h_inner = h_inner - asize;
         horisontal ++ ;
         number ++ ;
      }
      back ++ ;
      h_outer = h_outer + asize;
   }
   number ++ ;
} 

function paint_out()
{

   ctx.fillStyle = arr[number].rcolor;
   ctx.fillRect(h_inner + vcoffset, v_inner + hcoffset, width, height);
   // Write out numbers
   ctx.fillStyle = 'black';
   if (divisor < 4)ctx.fillText(number, h_inner + 3 + vcoffset, v_inner + 15 + hcoffset);
}

// HERE IS ANIMATION FUNCTIONS

function initanime()
{
   // CALLED FROM FORM
   size = 0;
   adder = -1;
   run = 1;
   refresh = setInterval(redraw, 1);
}

function stopanime()
{
   // CALLED FROM FORM
   adder = 0;
   size = 0;
   clearInterval(refresh);
}


// THIS IS MAIN FORM CALL AT LOAD

function first_call()
{
   canvas = document.getElementById("myCanvas");
   ctx = canvas.getContext("2d");
   reinitiate();
}

function reinitiate()
{
   // Fetch values from form
   numbRange = document.Jdoit.rangeN.value * 1;
   numberStart = document.Xdoit.start_At.value * 1;
   divisorGlobal = document.Zdoit.sqsize.value * 1;
   xxled = document.Ldoit.xledf.value * 1;
   yyled = document.Ldoit.yledf.value * 1;
   range=numbRange+10000;
   start=numberStart-10000;
   // Call the functions
   isPrime();
   size_font_square();
   arraysize();
   recheck();
}

// Calculate primes in range
function isPrime()
{
   n = range;
   // Eratosthenes algorithm to find all primes under n
   upperLimit = Math.sqrt(n);

   // Make an array from 2 to (n - 1)
   primearray[0] = false;
   primearray[1] = false;
   for (var i = 0; i < n; i ++ )
   {
      primearray.push(true);
   }

   // Remove multiples of primes starting from 2, 3, 5, ...
   i = 2;
   while (i <= upperLimit)
   {
      if (primearray[i])
      {
         for (var j = i * i; j < n; j += i)
         {
            primearray[j] = false;

         }
      }
      i ++ ;
   }
   return primearray;
}

// Set paintout size
function size_font_square()
{

   divisorGlobal = divisorGlobal + size;

   // Set size range 1 -> 100
   if (divisorGlobal == 0)
   {
      divisorGlobal = 1;
   }
   else if (divisorGlobal > 100)
   {
      divisorGlobal = divisorGlobal - 1;
   }
   // Write out Zoom factor to form
   document.Zdoit.sqsize.value = divisorGlobal;
   // Global magnitude objects
   divisor = divisorGlobal;
   // Set fontsize
   fstor = 17 / divisor;
   ctx.font = "" + fstor + "px Arial";
   // Set distance squares
   asize = 67 / divisor;
   // Set square size
   storlek = 54;
   height = storlek / divisor;
   width = storlek / divisor;
}

function getsquare()
{
squareroot=Math.sqrt(numbRange);
squareroot=squareroot+1;
sqval=squareroot*squareroot;
return sqval;
}

function arraysize()
{
   //getsquare();
   
   for ( i = start; i <= range; i ++ )
   {
      arr[i] =
      {
         count : i,
         fcolor : 'black',
         rheight : 100,
         rwidth : 100,
         rcolor : 'white'
      }

   }

}

// HERE IS FUNCTIONS REACTING AT CHANGE OF CHECKBOXES

function recheck()
{
   notchecked();
   if (document.getElementById('pos').checked == true)
   {
      pos_checked();

   }
   if (document.getElementById('neg').checked == true)
   {
      neg_checked();

   }
   if (document.getElementById('o').checked == true)
   {
      odd_checked();

   }
   if (document.getElementById('e').checked == true)
   {
      even_checked();

   }
   if (document.getElementById('p').checked == true)
   {
      prime_checked();

   }
   if (document.getElementById('sq').checked == true)
   {
      square_checked();

   }
   redraw();
}

function notchecked()
{
   // document.write(numberStart); p.stop();
   for (var k = start; k <= range; k ++ )
   {
      arr[k].rcolor = 'white';
   }
}


function square_checked()
{

   for (var k = start; k <= range; k ++ )
   {
      square = Math.sqrt(k, 2);
      negsquare = Math.sqrt( - k, 2);
      if(square - Math.floor(square) == 0)  arr[k].rcolor = 'red';
      if(k < 0 && negsquare - Math.floor(negsquare) == 0) arr[k].rcolor = 'orange';


   }

}

function prime_checked()
{
   for (var k = start; k <= range; k ++ )
   {
      if((primearray[k]) == true ) arr[k].rcolor = 'blue';
   }
}

function pos_checked()
{
   for (var k = start; k <= range; k ++ )
   {
      if(k > 0) arr[k].rcolor = 'yellow';
   }
}

function neg_checked()
{
   for (var k = start; k <= range; k ++ )
   {
      if(k < 0) arr[k].rcolor = 'gray';
   }
}

function odd_checked()
{
   for (var k = start; k <= range; k ++ )
   {
      if((k / 2) % 1 != 0) arr[k].rcolor = 'pink';
   }
}

function even_checked()
{
   for (var k = start; k <= range; k ++ )
   {
      if((k / 2) % 1 == 0) arr[k].rcolor = 'lightblue';
   }
}


// MANIPULATE OUTPUT FUNCTIONS

function startPos()
{

   numberStart = document.Xdoit.start_At.value * 1;
   redraw();
}

function next()
{

   size = 0;
   adder = + 1;
   redraw();
}

function prev()
{
   size = 0;
   adder = - 1;
   redraw();
}


function zoomin()
{
   //adder = 0;
   size = - 1;
   size_font_square();
   redraw();
}

function zoomout()
{
   //adder = 0;
   size = + 1;
   size_font_square()
   redraw();
}

function square_size()
{
   size = 0;
   divisorGlobal = document.Zdoit.sqsize.value * 1;
   size_font_square()
   redraw();
}

function offset()
{
   size = 0;
   adder = 0;
   xxled = document.Ldoit.xledf.value
   yyled = document.Ldoit.yledf.value
   redraw();
}

function plusX()
{

   xxled ++ ;
   document.Ldoit.xledf.value = xxled;
   redraw();
}

function minusX()
{

   xxled -- ;
   document.Ldoit.xledf.value = xxled;
   redraw();
}

function plusY()
{

   yyled ++ ;
   document.Ldoit.yledf.value = yyled;
   redraw();
}

function minusY()
{

   yyled -- ;
   document.Ldoit.yledf.value = yyled;
   redraw();
}


</script>

</div>

<div id="footer" style="background-color:lightblue;clear:both;text-align:center;">
Copyright © Jonas Thörnvall</div>

</div>

</body>
</html>

[toc] | [prev] | [next] | [standalone]


#23553

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2014-03-12 01:27 +0100
Message-ID<6778903.525aRzo9tQ@PointedEars.de>
In reply to#23547
Christoph Michael Becker wrote:

> jonas.thornvall@gmail.com wrote:
>> I try to get the gist of what you saying but for me it is all very
>> confusing. Do you mean something like this?
>> 
>> var arr = new Array();
>> for (var i = -500; i <= +500; i ++ )
>> {
>> arr[i] =
>>    {
>>       count : i,
>>       fcolor : 'black',
>>       rheight : 100,
>>       rwidth : 100,
>>       rcolor : 'white'
>>    }
>> }
> 
> Yes.  If you prefer, you can use another variable to store the object
> first, e.g.:
> 
>   {
>     var obj = {...};
>     arr[i] = obj;
>   }

It is not possible to store objects in variables/properties.  It is only 
possible to store *references to* objects.  References are values.  The 
difference is important because it emphasizes that there can be several 
references to the same object, and there can be unnamed references. [0]
In short: Objects have identity, not name.

The above Block statement is equivalent to

  var obj;

  {
    obj = {...};
    arr[i] = obj;
  }

which means:

1. Declare a (here: local) variable named “obj”.  (This happens *before*
   control enters the Block statement, even before all other statements in
   that local context are executed.) [1]

2. Create an Object instance, initialize it with the specified properties,
   and return a reference to it (“return” with regard to the algorithm only;
   understood as the *evaluation value*). [2]

3. Assign to “obj” the reference to the newly created object. [3]

4. Retrieve the reference to the newly created object from “obj” [4] and
   store it in (copy it to) the property of the object referred to by “arr”
   that is specified by the value of “i” converted to String.  (Create
   the property if it does not exist and their are no provisions to creating
   it. [5]  If “arr” is referring to an Array instance, modify the
   value of its “length” property value if the value of “i” is an index
   value and the value of “i” converted to String, then converted to
   unsigned 32-bit integer, is greater than the last index in the array.
   [6])

5. Set the evaluation value of the Block statement to “obj” because it is
   the evaluation value of the assignment, which is the last statement
   in the Block. [7]

_______
[0] <http://ecma-international.org/ecma-262/5.1/#sec-4.2.1>
[1] <http://ecma-international.org/ecma-262/5.1/#sec-12.2>
[2] <http://ecma-international.org/ecma-262/5.1/#sec-11.1.5>
[3] <http://ecma-international.org/ecma-262/5.1/#sec-11.13.1>
[4] <http://ecma-international.org/ecma-262/5.1/#sec-10.3.1>
[5] <http://ecma-international.org/ecma-262/5.1/#sec-8.7.2>
[6] <http://ecma-international.org/ecma-262/5.1/#sec-15.4.5.1>
[7] <http://ecma-international.org/ecma-262/5.1/#sec-12.1>
-- 
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]


#23554

FromChristoph Michael Becker <cmbecker69@arcor.de>
Date2014-03-12 01:44 +0100
Message-ID<531fadf3$0$6667$9b4e6d93@newsspool2.arcor-online.net>
In reply to#23553
Thomas 'PointedEars' Lahn wrote:

> Christoph Michael Becker wrote:
> 
>> jonas.thornvall@gmail.com wrote:
>>> I try to get the gist of what you saying but for me it is all very
>>> confusing. Do you mean something like this?
>>>
>>> var arr = new Array();
>>> for (var i = -500; i <= +500; i ++ )
>>> {
>>> arr[i] =
>>>    {
>>>       count : i,
>>>       fcolor : 'black',
>>>       rheight : 100,
>>>       rwidth : 100,
>>>       rcolor : 'white'
>>>    }
>>> }
>>
>> Yes.  If you prefer, you can use another variable to store the object
>> first, e.g.:
>>
>>   {
>>     var obj = {...};
>>     arr[i] = obj;
>>   }
> 
> It is not possible to store objects in variables/properties.  It is only 
> possible to store *references to* objects.  References are values.  The 
> difference is important because it emphasizes that there can be several 
> references to the same object, and there can be unnamed references. [0]
> In short: Objects have identity, not name.

Yes, of course you're right.  Thanks for pointing out my mistake. :)

-- 
Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#23525

FromChristoph Michael Becker <cmbecker69@arcor.de>
Date2014-03-11 16:26 +0100
Message-ID<531f2b05$0$6660$9b4e6d93@newsspool2.arcor-online.net>
In reply to#23521
jonas.thornvall@gmail.com wrote:

> Well i sure did, this for loop code will store values of index i at
> their respective  negative indexes. Just run it. There is no problem
> to store and reach values at negative indexes but i want to store
> objects not values.
> 
> <script type="text/javascript">
> var arr=[];
> for (i=10;i>=-20;i--) {arr[i]=i;}
> arr[-22]=-22;
> for (i=10;i>=-22;i--) {document.write(arr[i],",");}
> </script>

As Evertjan has already pointed out, there are no negative array
indexes, but the "index" is rather the name of a property of the array
object in this case.  Cf. the following snippet:

  var a = [];
  a[-1] = "foo";
  window.alert(a.length); // shows 0!

I suggest to use ECMAScript Arrays the way they're meant to be used, and
use indexes from 0 to n, and scale them as appropriate.

BTW: please try to avoid Google Groups for posting if possible; at least
avoid overlong lines when posting via GG.

-- 
Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#23526

FromCarlos Pedro <carlospedr@gmail.com>
Date2014-03-11 09:21 -0700
Message-ID<98c7aba7-2930-4215-a535-0369b3b722d7@googlegroups.com>
In reply to#23525
Bellow I post a little bit of code and return values from the console in chrome.
my_arr is an array, but my_arr[-100] is not part of the array like you
can see below.

> var my_arr = new Array();
  undefined
> var obj = "a property";
  undefined
> my_arr[-100] = obj;
  "a property"
> my_arr.indexOf(obj);
  -1
> my_arr["-100"]
  "a property"
> Array.isArray(my_arr);
  true

Carlos Pedro

[toc] | [prev] | [next] | [standalone]


#23529

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2014-03-11 18:01 +0100
Message-ID<60636642.clnVRmuXiz@PointedEars.de>
In reply to#23525
Christoph Michael Becker wrote:

> jonas.thornvall@gmail.com wrote:
>> Well i sure did, this for loop code will store values of index i at
>> their respective  negative indexes. Just run it. There is no problem
>> to store and reach values at negative indexes but i want to store
>> objects not values.
>> 
>> <script type="text/javascript">
>> var arr=[];
>> for (i=10;i>=-20;i--) {arr[i]=i;}
>> arr[-22]=-22;
>> for (i=10;i>=-22;i--) {document.write(arr[i],",");}
>> </script>
> 
> As Evertjan has already pointed out,

… being wrong on several accounts …

> there are no negative array indexes, but the "index" is rather the name of
> a property of the array object in this case.

In *all* cases.  It is only that with Array instances some property names, 
the array indexes, are special.

> I suggest to use ECMAScript Arrays the way they're meant to be used, and
> use indexes from 0 to n, and scale them as appropriate.

As long as the “length” property is not used directly, it can be useful to 
have an *Array* instance with user-defined properties whose names are string 
representations of negative numbers, positive numbers greater than 2³² − 1,  
and non-integers.
 
> BTW: please try to avoid Google Groups for posting if possible; at least
> avoid overlong lines when posting via GG.

ACK.

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


#23535

FromChristoph Michael Becker <cmbecker69@arcor.de>
Date2014-03-11 19:15 +0100
Message-ID<531f52ab$0$6670$9b4e6d93@newsspool2.arcor-online.net>
In reply to#23529
Thomas 'PointedEars' Lahn wrote:

> Christoph Michael Becker wrote:
> 
>> jonas.thornvall@gmail.com wrote:
>>> Well i sure did, this for loop code will store values of index i at
>>> their respective  negative indexes. Just run it. There is no problem
>>> to store and reach values at negative indexes but i want to store
>>> objects not values.
>>>
>>> <script type="text/javascript">
>>> var arr=[];
>>> for (i=10;i>=-20;i--) {arr[i]=i;}
>>> arr[-22]=-22;
>>> for (i=10;i>=-22;i--) {document.write(arr[i],",");}
>>> </script>
>>
>> As Evertjan has already pointed out,
> 
> … being wrong on several accounts …
> 
>> there are no negative array indexes, but the "index" is rather the name of
>> a property of the array object in this case.
> 
> In *all* cases.  It is only that with Array instances some property names, 
> the array indexes, are special.

Thanks for the clarification. :)

>> I suggest to use ECMAScript Arrays the way they're meant to be used, and
>> use indexes from 0 to n, and scale them as appropriate.
> 
> As long as the “length” property is not used directly, it can be useful to 
> have an *Array* instance with user-defined properties whose names are string 
> representations of negative numbers, positive numbers greater than 2³² − 1,  
> and non-integers.

While you're surely right that having "non negative" properties *can* be
useful sometimes, it might often be confusing (particularly for
beginners).  Not only the length property will not work as "expected",
but also several of the methods of Array.prototype, e.g. shift() and
unshift().  One does not have to use these, but than one could even use
an object that does not "inherit" from Array at all.  Element access via
the bracket notation as well as for loops will work on such "arrays".
Quite fascinating! :)

BTW, I wonder if there are ECMAScript implementations which implement
the indexed elements of an Array object as an array instead of a hashmap.

-- 
Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#23537

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2014-03-11 20:32 +0100
Message-ID<1406720.0V7e0g0dhT@PointedEars.de>
In reply to#23535
Christoph Michael Becker wrote:

> Thomas 'PointedEars' Lahn wrote:
>> Christoph Michael Becker wrote:
>>> I suggest to use ECMAScript Arrays the way they're meant to be used, and
>>> use indexes from 0 to n, and scale them as appropriate.
>> 
>> As long as the “length” property is not used directly, it can be useful
>> to have an *Array* instance with user-defined properties whose names are
>> string representations of negative numbers, positive numbers greater than
>> 2³² − 1, and non-integers.
> 
> While you're surely right that having "non negative" properties *can* be
> useful sometimes, it might often be confusing (particularly for
> beginners).

Non sequitur.  I expect people to use their brain while programming, IOW not 
to treat those special arrays as if they were ordinary arrays.

> Not only the length property will not work as "expected",

Depends on the implementation.  You are forgetting getters.

> but also several of the methods of Array.prototype, e.g. shift() and
> unshift(). 

You could override them.

> One does not have to use these, but than one could even use
> an object that does not "inherit" from Array at all.

But it makes sense to have an object that works like an Array in all other 
respects.  Many Array prototype methods are intentionally generic.

<http://PointedEars.de/es-matrix?filter=Array.prototype>

> Element access via the bracket notation as well as for loops will work on 
> such "arrays".

Depends on the implementation, see jsx.array.BigArray in 
<http://PointedEars.de/wsvn/JSX/trunk/array.js>.

I have written this to increase the upper border for indexes (from the 
getPrimes() discussion), and index < 0 gets you the same as in Python (with 
the bracket property accessor: only if Proxy is supported).

But now I am thinking of a property defining whether you can have negative 
indexes on the object, modifying that behavior slightly.  FWIW, the “length” 
property could then yield the difference between the maximum positive and 
the minimum negative index or just the maximum positive index + 1 as it 
always had; how did you get the idea that “for” loops would stop working for 
those objects *per se*?

> Quite fascinating! :)

Indeed.
 
-- 
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]


Page 2 of 3 — ← Prev page 1 [2] 3  Next page →

Back to top | Article view | comp.lang.javascript


csiph-web