Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #23530
| Newsgroups | comp.lang.javascript |
|---|---|
| Date | 2014-03-11 10:40 -0700 |
| References | (1 earlier) <XnsA2ED695A14973eejj99@194.109.133.133> <868d8999-f1b7-49bb-a33c-4e76b00ecafa@googlegroups.com> <XnsA2ED8F0737DBBeejj99@194.109.133.133> <fbd15953-edfd-4456-b4c8-7b31417ecd24@googlegroups.com> <XnsA2EDA6E3485F7eejj99@194.109.133.133> |
| Message-ID | <253eca00-abda-47da-8388-8a621f36fffd@googlegroups.com> (permalink) |
| Subject | Re: arr.push(obj); |
| From | jonas.thornvall@gmail.com |
Den tisdagen den 11:e mars 2014 kl. 16:24:20 UTC+1 skrev Evertjan.:
> jonas.thornvall@gmail.com wrote on 11 mrt 2014 in comp.lang.javascript:
>
>
>
> >> That is impossible. Arrays have no negative indexes, see above.
>
> > Well i showed you it can be done, was i just lucky??????
>
>
>
> No it cannot be done and [so] you did not show me.
>
>
>
> You are just extremely unlucky not comprehending this yet.
>
>
>
> The thing we call an index of an array can only be a non negative integer.
>
>
>
> All kind of array-functions expect of an array where the elements have
>
> numeric order within these confines.
>
>
>
> for instance, how would you reverse a group of elements with no order,
>
> or join them sequencially without order?
>
>
>
> ============== some array functions =========================
>
> length returns the highest index + 1
>
>
>
> join() joins all elements of an array into a string
>
>
>
> lastIndexOf() searches the array for an element, starting at the end,
>
> and returns its position
>
>
>
> pop() Removes the last element of an array, and returns that element
>
>
>
> push() Adds new elements to the end of an array,
>
> and returns the new length
>
>
>
> reverse() Reverses the order of the elements in an array
>
>
>
> shift() Removes the first element of an array, and returns that element
>
>
>
> slice() Selects a part of an array, and returns the new array
>
>
>
> splice() Adds/Removes elements from an array
>
>
>
> unshift() Adds new elements to the beginning of an array,
>
> and returns the new length
>
> ========================================
>
>
>
> Now an object can have keys, they are NOT called indexes:
>
>
>
> var obj = {};
>
>
>
> obj[1]
>
> obj[-1]
>
> obj[-7.555]
>
> obj['foo']
>
>
>
> but you cannot use any of the above functions,
>
> as long as it is not an array too,
>
> defined with
>
>
>
> var obj = [];
>
>
>
> and even then obj[1] will be the only array element,
>
> so obj.length will be 2.
>
>
>
> =============================================
>
>
>
> Synopsis:
>
>
>
> An array is not the same as an object.
>
>
>
> The elements of an array are indicated by their index.
>
> An array cannot have other indexes than non-negative integers.
>
> The elements of an array have order.
>
> This order makes most of the above functions possible.
>
>
>
> An object's elements are indicated by a key,
>
> this can be any string or even a number the probably will be converted to a
>
> string.
>
> The elements of an object have no order.
>
>
>
> However an array is also an object, so can have elements indicated by an
>
> index, and additionally elements that are indicated by keys.
>
>
>
> An object not defined as an array is not an array.
>
>
>
> =======================================
>
>
>
> Do you still hold that an array can have negative index values?
>
>
>
>
>
Please man just run the code.
1.It is an array? I answer yes to that.
2.The numbers i put into arr represent indexes not keys? I answer yes to that.
2.It reach the values stored at the negative values of index? I answer yes to that.
By the way I run firefox.
<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>
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
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
csiph-web