Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Array in javascript

7 views
Skip to first unread message

Leszek

unread,
Feb 2, 2006, 3:07:03 PM2/2/06
to
Hi.

Is it possible in javascript to operate on an array without knowing how mamy
elements it has?
What i want to do is sending an array to a script, and this script should
add all values from that array

Could you show me a little example how to do this?

Thanks.
Leszek


Thomas 'PointedEars' Lahn

unread,
Feb 2, 2006, 3:36:31 PM2/2/06
to
Leszek wrote:

> Is it possible in javascript to operate on an array without knowing how
> mamy elements it has?

Of course. This is what the e.g. `length' property of Array objects is for.

> What i want to do is sending an array to a script, and this
> script should add all values from that array
>
> Could you show me a little example how to do this?

Depends on what you mean by "sending an array to a script" (which array,
which script, client-side or server-side, send from where to where?) and by
"script should add all values from that array" (add from where exactly to
which?)


PointedEars

VK

unread,
Feb 2, 2006, 4:17:59 PM2/2/06
to

Leszek wrote:
> Hi.
>
> Is it possible in javascript to operate on an array without knowing how mamy
> elements it has?

JavaScript array is Dynamic Sparse Jagged Array. That can be too much
of adjectives for one time :-) but the first one means that can add new
elements to array without ReDim / resize() it.

var myArray = new Array(); // 0 elements
myArray[0] = 0;
...
...
myArray[1000] = 1000;

About other adjectives (and about JavaScript arrays at whole) you can
read at:
<http://www.geocities.com/schools_ring/ArrayAndHash.html>

> What i want to do is sending an array to a script, and this script should
> add all values from that array
> Could you show me a little example how to do this?

As it was pointed out it depends on how and in what form are you
getting the original data for your array.

Guillaume

unread,
Feb 2, 2006, 4:47:33 PM2/2/06
to
Leszek

> Is it possible in javascript to operate on an array without knowing how mamy
> elements it has?

I don't think, there is no function like 'map' or 'apply'. However, they
are not difficult to implement because you always know the size of an
array: array.length;

--
My desktop is worth a million of dollars. Put an icon on it.
http://www.milliondollarscreenshot.com/

Thomas 'PointedEars' Lahn

unread,
Feb 2, 2006, 4:49:16 PM2/2/06
to
VK wrote:

> Leszek wrote:
>> Is it possible in javascript to operate on an array without knowing how
>> mamy elements it has?
>
> JavaScript array is Dynamic Sparse Jagged Array. That can be too much
> of adjectives for one time :-)

But I am sure you can invent more just to cover your lack of knowledge and
understanding of the basics.

> but the first one means that can add new
> elements to array without ReDim / resize() it.
>
> var myArray = new Array(); // 0 elements
> myArray[0] = 0;
> ...
> ...
> myArray[1000] = 1000;

You did not answer the question of the OP _at all_. Figures.



> About other adjectives (and about JavaScript arrays at whole) you can
> read at:
> <http://www.geocities.com/schools_ring/ArrayAndHash.html>

This text contains a lot of, if not consists mainly of, factually incorrect
information, presented as being the truth despite of that. Readers are
strongly recommended to ignore it, to handle all statements of its author
regarding (proper) software development with extreme care, and to read
previous discussions on the subject instead.

<URL:http://groups.google.com/groups?as_q=Array&as_ugroup=comp.lang.javascript&scoring=d&filter=0>
<URL:http://groups.google.com/groups?as_uauthors=VK&as_ugroup=comp.lang.javascript&scoring=d&filter=0>

PointedEars

Jambalaya

unread,
Feb 2, 2006, 4:58:52 PM2/2/06
to
Leszek wrote:
> Hi.
>
> Is it possible in javascript to operate on an array without knowing how mamy
> elements it has?

Yes.

> What i want to do is sending an array to a script, and this script should
> add all values from that array
>
> Could you show me a little example how to do this?

This is the smallest example I could write:

<html><head><title>Little Sum Function</title></head>
<body><script type="text/javascript">
function s(a){return Function('return '+a.join('+'))()}
document.write(s([1,654,2,5,489,51,3851,681,32,5,0]))
</script></body></html>

VK

unread,
Feb 2, 2006, 5:13:43 PM2/2/06
to

Thomas 'PointedEars' Lahn wrote:
> VK wrote:
>
> > Leszek wrote:
> >> Is it possible in javascript to operate on an array without knowing how
> >> mamy elements it has?
> >
> > JavaScript array is Dynamic Sparse Jagged Array. That can be too much
> > of adjectives for one time :-)
>
> But I am sure you can invent more just to cover your lack of knowledge and
> understanding of the basics.

JavaScript array is Dinamic, is Sparse and is Jagged. These three core
features are important to know to operate properly with arrays and get
expected results.

<http://www.geocities.com/schools_ring/ArrayAndHash.html> is the only
one known (to me at least) resource there all three features along with
other information would be named and illustrated properly: all within
the same page. Unfortunately (after careful reading and searching) this
is still the only resource I can endorse for JavaScript array
information.

It should be updated though by removing some no so relevant part at the
bottom and by adding new array methods from JavaScript 1.6 (Firefox 1.5)

Thomas 'PointedEars' Lahn

unread,
Feb 2, 2006, 5:44:52 PM2/2/06
to
Jambalaya wrote:

> Leszek wrote:
>> What i want to do is sending an array to a script, and
>> this script should add all values from that array
>>
>> Could you show me a little example how to do this?
>
> This is the smallest example I could write:
>
> <html>
> <head><title>Little Sum Function</title></head>
> <body><script type="text/javascript">
> function s(a){return Function('return '+a.join('+'))()}
> document.write(s([1,654,2,5,489,51,3851,681,32,5,0]))
> </script></body></html>

Nice[1] :)

Not shorter, but Valid:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"><head><meta
http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<title>Little Adder</title></head><script
type="text/javascript">document.write(Function("return "
+[1,654,2,5,489,51,3851,681,32,5,0].join("+"))());</script>


Regards,
PointedEars
___________
[1] especially because there is no evil[tm] eval()

Evertjan.

unread,
Feb 2, 2006, 5:53:04 PM2/2/06
to
Jambalaya wrote on 02 feb 2006 in comp.lang.javascript:

> This is the smallest example I could write:
>
> <html><head><title>Little Sum Function</title></head>
> <body><script type="text/javascript">
> function s(a){return Function('return '+a.join('+'))()}
> document.write(s([1,654,2,5,489,51,3851,681,32,5,0]))
> </script></body></html>
>

<script type="text/javascript">
alert(eval([1,654,2,5,489,51,3851,681,32,5,0].join('+')));
</script>

or for the (eval==evil)-ers:

<script type="text/javascript">
var b=0,a=[1,654,2,5,489,51,3851,681,32,5,0],z=a.length;
while(z)b+=a[--z];alert(b)
</script>


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

RobG

unread,
Feb 2, 2006, 6:13:05 PM2/2/06
to
Leszek wrote:
[...]

> What i want to do is sending an array to a script, and this script should
> add all values from that array
>
> Could you show me a little example how to do this?

// An array of numbers, some as strings
var A = [2,'5',8,'2',4];

// A function that adds all the elements of an array
function addEm(X)
{
var i = X.length;
var sum = 0;
while(i--) sum += +X[i];
return sum;
}

// Show it in action
alert( addEm(A) );


If there is any chance that some of the elements might not be numbers,
then that should be checked before attempting addition:

var A = [2,'blah','5',8,2,4];

function addEm(X)
{
var x, i = X.length;
var sum = 0;
while(i--) {
x = +X[i];
if ( !isNaN(x) ) sum += x;
}
return sum;
}

--
Rob

Ian Collins

unread,
Feb 3, 2006, 2:23:36 AM2/3/06
to
Leszek wrote:
> Hi.
>
> Is it possible in javascript to operate on an array without knowing how mamy
> elements it has?
> What i want to do is sending an array to a script, and this script should
> add all values from that array
>
I think the previous responses over looked the use of
for( var n in array ) {} as a method for iterating over an array.

> Could you show me a little example how to do this?
>

function test( names )
{
for( var name in names )
{
// do something.
}
}

--
Ian Collins.

VK

unread,
Feb 3, 2006, 2:52:08 AM2/3/06
to

Ian Collins wrote:
> I think the previous responses over looked the use of
> for( var n in array ) {} as a method for iterating over an array.
>
> > Could you show me a little example how to do this?
> >
>
> function test( names )
> {
> for( var name in names )
> {
> // do something.
> }
> }

for-in loop has nothing to do with *array*, it's an iterator over
enumerable properties of object.

Try this to understand the difference:

var arr = [1,2,3];
arr.foo = 'bar';

for (var i=0; i<arr.length; i++) {
alert(arr[i]);
}

for (var p in arr) {
alert(p);
}

Richard Cornford

unread,
Feb 3, 2006, 3:12:53 AM2/3/06
to
VK wrote:
> Thomas 'PointedEars' Lahn wrote:
>> VK wrote:
<snip>

>>> JavaScript array is Dynamic Sparse Jagged Array. That
>>> can be too much of adjectives for one time :-)
>>
>> But I am sure you can invent more just to cover your lack
>> of knowledge and understanding of the basics.
>
> JavaScript array is Dinamic, is Sparse and is Jagged.

Can you justify applying the term "jagged" to a javascript array when
they can only have a single dimension?

<snip>
> <http://www.geocities.com/schools_ring/Array ...
<snip>
> ... . Unfortunately (after careful reading and searching)


> this is still the only resource I can endorse for JavaScript
> array information.

<snip>

Your willingness to endorse your own page is not significant (beyond the
observation that your tendency to always choose the worst option
available means that your endorsement may be taken as a condemnation by
reasoning observers). The important consideration is whether it could be
endorsed by anyone who actually understands javascript. You have tried
to get such an endorsement from contributors to this group and the
reactions you got were anything but an endorsement.

Richard.


VK

unread,
Feb 3, 2006, 3:36:26 AM2/3/06
to

Richard Cornford wrote:
> Can you justify applying the term "jagged" to a javascript array when
> they can only have a single dimension?

This is exactly the case with JavaScript array wich is a single
dimension array when looking at it "from the top". But it can have
other arrays as its elements. Array of arrays is called in the
programming "jagged array".
We may of course continue to stay on the position that nothing of
regular programming is applicable to JavaScript - neither in terms nor
in technology :-)
In such case array of arrays is called "jagged" everywhere but in
JavaScript it's just "array of arrays" :-)

Jagged nature of JavaScript array is really important to know and
understand for say array sorting.

> Your willingness to endorse your own page is not significant (beyond the
> observation that your tendency to always choose the worst option
> available means that your endorsement may be taken as a condemnation by
> reasoning observers). The important consideration is whether it could be
> endorsed by anyone who actually understands javascript. You have tried
> to get such an endorsement from contributors to this group and the
> reactions you got were anything but an endorsement.

This article is not perfect and I willing to update it and make it even
more transparent. I would like to link some reputable public source
instead from say Mozilla.org or MSDN or IBM.com etc. Unfortunately
anything of this kind is either incomplete, or confusing or (more
often) factually wrong.

Ian Collins

unread,
Feb 3, 2006, 3:52:26 AM2/3/06
to
VK wrote:
> Ian Collins wrote:
>
>>I think the previous responses over looked the use of
>>for( var n in array ) {} as a method for iterating over an array.
>>
>>
>>>Could you show me a little example how to do this?
>>>
>>
>>function test( names )
>>{
>> for( var name in names )
>> {
>> // do something.
>> }
>>}
>
>
> for-in loop has nothing to do with *array*, it's an iterator over
> enumerable properties of object.
>
True, I've been using too many objects as associative arrays....

--
Ian Collins.

Richard Cornford

unread,
Feb 3, 2006, 4:21:38 AM2/3/06
to
VK wrote:
> Richard Cornford wrote:
>> Can you justify applying the term "jagged" to a javascript
>> array when they can only have a single dimension?
>
> This is exactly the case with JavaScript array wich is a single
> dimension array when looking at it "from the top".

Javascript has single dimension arrays however you look at them.

> But it can have other arrays as its elements. Array of arrays
> is called in the programming "jagged array".

No, the concept of a jagged array can only be implemented in javascript
with an array of arrays, but that does not make the javascript array
jagged. Indeed, the very fact that you must have more than one Array in
order to implement the concept of 'jagged' means that the term _cannot_
apply to a javascript Array (singular).

And "in the programming" a 'jagged array' is not an array of arrays, as
is easily demonstrated by the Java array, which is a single array that
is multidimensional and jagged.

> We may of course continue to stay on the position that nothing
> of regular programming is applicable to JavaScript - neither
> in terms nor in technology :-)

We? You are exclusively and personally responsible for your own
incoherent ramblings.

> In such case array of arrays is called "jagged" everywhere
> but in JavaScript it's just "array of arrays" :-)

Everywhere? I think you will find that the term 'jagged' will normally
be applied with discrimination beyond your comprehension.

> Jagged nature of JavaScript array is really important to know
> and understand for say array sorting.

So it is important to understand that the javascript array is a single
dimension array and so cannot be 'jagged'.

>> Your willingness to endorse your own page is not significant
>> (beyond the observation that your tendency to always choose
>> the worst option available means that your endorsement may
>> be taken as a condemnation by reasoning observers). The
>> important consideration is whether it could be endorsed by
>> anyone who actually understands javascript. You have tried to
>> get such an endorsement from contributors to this group and
>> the reactions you got were anything but an endorsement.
>
> This article is not perfect and I willing to update it and make
> it even more transparent.

BODY {
display:none;
}

> I would like to link some reputable public source instead
> from say Mozilla.org or MSDN or IBM.com etc.

Bad sources of information often try to gain credibility by linking to
'reputable public sources'. What is up, you cannot find anything on
these sites that doesn't directly contradict your page?

> Unfortunately anything of this kind is either incomplete, or
> confusing or (more often) factually wrong.

LOL. You own page is incomplete, confusing and factually wrong. That is
precisely what was said of it when you attempted to get this group to
endorse it.

On the other hand, one of the advantages of your page is that some of
the 'factually wrong' is so obvious that only the complete novice is
likely to give any credence to the rest of its text.

Richard.


VK

unread,
Feb 3, 2006, 4:37:53 AM2/3/06
to

Richard Cornford wrote:
> same old story

All arguments has been spelled many times over the last year.
You are welcome to give array-related advises from your point of view:
and I reserve the same for mine.

Eventually only the practice (who's picture allow to create effective
predictable code) is the way to check a theory. A theory in
contradiction with the practical experience is worthless IMHO.

VK

unread,
Feb 3, 2006, 5:01:11 AM2/3/06
to

Richard Cornford wrote:
> No, the concept of a jagged array can only be implemented in javascript
> with an array of arrays, but that does not make the javascript array
> jagged. Indeed, the very fact that you must have more than one Array in
> order to implement the concept of 'jagged' means that the term _cannot_
> apply to a javascript Array (singular).

Sorry for making addons to my post, but there is a logical (not
pragrammatical) error in the above reasonning:

Neither C++ or Java array are *obligated* to be multi-dimensional. In
any language I can perfectly create a simple single-dimention array.
Applying your own thesis: "The very fact that you must have more than
one dimension in order to implement the concept of `multi-dimensional'
means that the term _cannot_ apply to a C++ array (singular)."

This logical casus can be solved is we realize that "milti-dimensional"
vs. "jagged" are applied to the *model potention* and not to a
particular given array X, Y or Z.

Richard Cornford

unread,
Feb 3, 2006, 6:35:35 AM2/3/06
to
VK wrote:
> Richard Cornford wrote:
>> No, the concept of a jagged array can only be implemented in
>> javascript with an array of arrays, but that does not make
>> the javascript array jagged. Indeed, the very fact that you
>> must have more than one Array in order to implement the
>> concept of 'jagged' means that the term _cannot_ apply to a
>> javascript Array (singular).
>
> Sorry for making addons to my post, but there is a logical
> (not pragrammatical) error in the above reasonning:

It is partly the fact that you cannot recognise logical errors that
leads me to question your rationality.

> Neither C++ or Java array are *obligated* to be multi-dimensional.

While javascript Arrays cannot be multi-dimensional.

> In any language I can perfectly create a simple
> single-dimention array. Applying your own thesis:
> "The very fact that you must have more than
> one dimension in order to implement the concept of
> `multi-dimensional' means that the term _cannot_ apply
> to a C++ array (singular)."

In that case the parallel statement is that because you have to have
more than one dimension before something is multi-dimensional then a
_dimension_ (singular) cannot be multi-dimensional. That is, the term
'multi-dimensiton' cannot be applied to a dimension.

The term is applicable to arrays in certain languages because they have
the potential to have multiple dimensions, whether the actually do or
not (and the Java array has the potential to be jagged as well).

It is like stating that the javascript Array is a sparse array. Actual
array instances do not need to be sparse (in the sense of having fewer
than - array.length - 'array index' properties), but the configuration
of an instance does not alter the nature of the javascript Array.

> This logical casus can be solved is we realize that
> "milti-dimensional" vs. "jagged" are applied to the
> *model potention* and not to a particular given array
> X, Y or Z.

The javascript array has no potential to have multiple dimensions and so
no potential to be 'jagged'. Both concepts can be successfully
implemented/emulated with javascript but that can not be done with a
single javascript Array, and so the terms 'multi-dimensional' and
'jagged' are not applicable as characteristics of a javascript Array.

Richard.


Richard Cornford

unread,
Feb 3, 2006, 6:35:50 AM2/3/06
to
VK wrote:
> Richard Cornford wrote:
>> same old story
>
> All arguments has been spelled many times over the
> last year.

Yes they have, and you have presented no reasoned counter argument, only
the stubborn refusal to pay any attention.

> You are welcome to give array-related advises from
> your point of view: and I reserve the same for mine.

Your ability (and right) to post any nonsense you choose cannot be
denied. But your should have no expectation of being allowed to do so
without being criticised for doing so.

And I am subject to the same consideration. If I posted nonsense,
falsehoods and bad advice I expect (and even want) to be corrected and
criticised for doing so. But that doesn't seem to happen often; not
because I am intrinsically or inherently correct but because in the past
I have paid attention to such comments and learnt form them.

Initial ignorance of any subject is inevitable and as people learn they
make mistakes, but most learn form, instead of repeating, their
mistakes.

> Eventually only the practice (who's picture allow to create
> effective predictable code) is the way to check a theory.

But you don't write effective predictable computer code. You write a
chaotic mush half thought-out reasoning and pure voodoo. The last piece
of 'full working' code you posted to this group earned the epithet "the
most bizarre and obtuse storage method I've ever witnessed", with good
reason, and demonstrated a basic lack of understanding of standard
language constructs.

> A theory in contradiction with the practical experience
> is worthless IMHO.

A theory that is contradicted by reality is false, but it takes some
familiarity with testing and analysis methodologies to identify a real
contradiction. That perverse personal mental process that you like to
label 'logic' seems to significantly restrict your ability to create and
apply tests, or analyse the results. A fact that should have been
sufficiently flagged when you posted earlier in the week that your had
spent two months testing Mozilla browsers and concluded that they did
not support - document.styleSheets -, when they have done so since their
beta versions at least.

The notions that originate in your head are also theories, and the
'practical' results you achieve with them are so self evidently inferior
to what can demonstrably be achieved that even you should be questioning
them, and not at all surprised that nobody else gives you any credence
at all.

Richard.


VK

unread,
Feb 3, 2006, 6:57:21 AM2/3/06
to

Richard Cornford wrote:
> The javascript array has no potential to have multiple dimensions and so
> no potential to be 'jagged'. Both concepts can be successfully
> implemented/emulated with javascript but that can not be done with a
> single javascript Array, and so the terms 'multi-dimensional' and
> 'jagged' are not applicable as characteristics of a javascript Array.

It's too late and I'm too tired to continue this discussion right now.
But I bookmark this statement till the next array question - where
you'll have an opportunity to answer it without using words "dimension"
or "jagged" or "pseudo-dimension" (because pseudo-dimension directly
leads to "jagged"). From my humble and very possibly wrong point of
view it will be funny.

Randy Webb

unread,
Feb 3, 2006, 7:25:14 AM2/3/06
to
VK said the following on 2/3/2006 6:57 AM:

> Richard Cornford wrote:
>> The javascript array has no potential to have multiple dimensions and so
>> no potential to be 'jagged'. Both concepts can be successfully
>> implemented/emulated with javascript but that can not be done with a
>> single javascript Array, and so the terms 'multi-dimensional' and
>> 'jagged' are not applicable as characteristics of a javascript Array.
>
> It's too late and I'm too tired to continue this discussion right now.

Promise? To me, it's not a discussion, it is a one-sided statement from
Richard showing the flaws in what you are saying.

> But I bookmark this statement till the next array question - where
> you'll have an opportunity to answer it without using words "dimension"
> or "jagged" or "pseudo-dimension" (because pseudo-dimension directly
> leads to "jagged").

I can answer *any* question not directly related to mutil-dimensional
arrays without using any one of those three phrases, and in fact I
wouldn't even consider using any of those terms unless it was directly
related to the question.

> From my humble and very possibly wrong point of view it will be funny.

To date, most of your points of view with regards to Array's has been
dead wrong. The funny part is watching you trying to defend that position.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

Thomas 'PointedEars' Lahn

unread,
Feb 3, 2006, 8:27:45 AM2/3/06
to
VK wrote:

> Thomas 'PointedEars' Lahn wrote:
>> VK wrote:
>> > Leszek wrote:
>> >> Is it possible in javascript to operate on an array without knowing
>> >> how mamy elements it has?
>> >
>> > JavaScript array is Dynamic Sparse Jagged Array. That can be too much
>> > of adjectives for one time :-)
>>
>> But I am sure you can invent more just to cover your lack of knowledge
>> and understanding of the basics.
>
> JavaScript array is Dinamic, is Sparse and is Jagged.

Whatever this means to you.

> [...]


> <http://www.geocities.com/schools_ring/ArrayAndHash.html> is the only
> one known (to me at least) resource there all three features along with

> other information would be named and illustrated properly: [...]

That you do not understand the correct terms used in public specifications
and vendors' documentation does not mean that they are bad. That you do
not understand what was written before does not make your explanations,
based on your misconceptions, any better than it.

<URL:http://developer.mozilla.org/js/specs/ecma-262#a-15.4>
<URL:http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Literals#Array_Literals>
<URL:http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Predefined_Core_Objects:Array_Object>
<URL:http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array>
<URL:http://msdn.microsoft.com/library/en-us/script56/html/08e5f552-0797-4b48-8164-609582fc18c9.asp>
<URL:http://msdn.microsoft.com/library/en-us/jscript7/html/jsobjarray.asp>


PointedEars

RobG

unread,
Feb 3, 2006, 9:11:21 AM2/3/06
to
VK wrote:
> Ian Collins wrote:
>
>>I think the previous responses over looked the use of
>>for( var n in array ) {} as a method for iterating over an array.
>>
>>
>>>Could you show me a little example how to do this?
>>>
>>
>>function test( names )
>>{
>> for( var name in names )
>> {
>> // do something.
>> }
>>}
>
>
> for-in loop has nothing to do with *array*, it's an iterator over
> enumerable properties of object.

Strange comment - arrays are objects. For-in works fine provided you
deal with properties that aren't numbers.


> Try this to understand the difference:
>
> var arr = [1,2,3];
> arr.foo = 'bar';
>
> for (var i=0; i<arr.length; i++) {
> alert(arr[i]);
> }
>
> for (var p in arr) {
> alert(p);
> }

I guess you are suggesting that if some of the properties aren't
numbers, you'll get erroneous results. But that can happen with a for
loop too and is catered for in the solutions offered above (typeof and
isNaN tests are obvious choices).

Ian's suggested method offers significant speed benefits *if* the array
length is large *and* the array is very sparse - otherwise, there is
little to recommend it.

Neither of the above conditions were suggested by the OP, but the point
is useful to understand.


--
Rob

Randy Webb

unread,
Feb 3, 2006, 9:37:40 AM2/3/06
to
RobG said the following on 2/3/2006 9:11 AM:

> VK wrote:
>> Ian Collins wrote:
>>
>>> I think the previous responses over looked the use of
>>> for( var n in array ) {} as a method for iterating over an array.
>>>
>>>
>>>> Could you show me a little example how to do this?
>>>>
>>>
>>> function test( names )
>>> {
>>> for( var name in names )
>>> {
>>> // do something.
>>> }
>>> }
>>
>>
>> for-in loop has nothing to do with *array*, it's an iterator over
>> enumerable properties of object.
>
> Strange comment - arrays are objects. For-in works fine provided you
> deal with properties that aren't numbers.

VK confuses the hell out of me sometimes, but I think he confuses
himself more. What I think he meant was that for-in is not limited to
arrays but can be used on any object.

Duncan Booth

unread,
Feb 3, 2006, 10:20:41 AM2/3/06
to
RobG wrote:

>> for-in loop has nothing to do with *array*, it's an iterator over
>> enumerable properties of object.
>
> Strange comment - arrays are objects. For-in works fine provided you
> deal with properties that aren't numbers.
>

... and provided you aren't too choosy about the order in which you process
the array elements: the order of iteration produced by for..in is
undefined, and can suprise people who don't realise that.

If you don't believe me, try the following:

var a = ['a', 'b', 'c'];
a[4] = 'e'; a[3] = 'd';
for(var idx in a) {
alert(idx+"="+a[idx]);
};

The alerts in IE and Firefox go in the order 0,1,2,4,3 (although a
conforming ecmascript implementation could use any order it fancied).

John W. Kennedy

unread,
Feb 3, 2006, 10:27:43 AM2/3/06
to
Duncan Booth wrote:
> RobG wrote:
>
>>> for-in loop has nothing to do with *array*, it's an iterator over
>>> enumerable properties of object.
>> Strange comment - arrays are objects. For-in works fine provided you
>> deal with properties that aren't numbers.
>>
>
> .... and provided you aren't too choosy about the order in which you process
> the array elements: the order of iteration produced by for..in is
> undefined, and can suprise people who don't realise that.
>
> If you don't believe me, try the following:
>
> var a = ['a', 'b', 'c'];
> a[4] = 'e'; a[3] = 'd';
> for(var idx in a) {
> alert(idx+"="+a[idx]);
> };
>
> The alerts in IE and Firefox go in the order 0,1,2,4,3 (although a
> conforming ecmascript implementation could use any order it fancied).

Note, too, that "idx" above is treated as a string, not an integer.

--
John W. Kennedy
"But now is a new thing which is very old--
that the rich make themselves richer and not poorer,
which is the true Gospel, for the poor's sake."
-- Charles Williams. "Judgement at Chelmsford"

Thomas 'PointedEars' Lahn

unread,
Feb 3, 2006, 12:46:15 PM2/3/06
to
John W. Kennedy wrote:

> Duncan Booth wrote:
>> [...]


>> var a = ['a', 'b', 'c'];
>> a[4] = 'e'; a[3] = 'd';
>> for(var idx in a) {
>> alert(idx+"="+a[idx]);
>> };
>>
>> The alerts in IE and Firefox go in the order 0,1,2,4,3 (although a
>> conforming ecmascript implementation could use any order it fancied).
>
> Note, too, that "idx" above is treated as a string, not an integer.

However, this does not matter here. All property names are strings. In
fact, any expression as property name is subject to ToString() conversion
on property access. See ECMAScript Ed. 3, 11.2.1 and 15.4.

This means that the property accesses a["3"] and a[3], and ({3: 33})["3"]
and ({3: 33})[3] are equivalent.


PointedEars

VK

unread,
Feb 3, 2006, 1:14:08 PM2/3/06
to

Randy Webb wrote:
> To me, it's not a discussion, it is a one-sided statement from
> Richard showing the flaws in what you are saying.

And I'm showing the flaws in what he is saying while both are staying
away from Thomas'-like vocabulary. To me, it is a discussion. ;-)

> I can answer *any* question not directly related to mutil-dimensional
> arrays without using any one of those three phrases, and in fact I
> wouldn't even consider using any of those terms unless it was directly
> related to the question.

This loud statement is bookmarked too :-)

> To date, most of your points of view with regards to Array's has been
> dead wrong. The funny part is watching you trying to defend that position.

It was confirmed by many, including professional programmers and
programming specialists. As it brings them automatically to the
category of "people who knows no more or even less than VK does":- my
question would be what authority besides Richard Cornford would you
accept as an authority? I'm really open for requests: except a message
form the Lord and a wiki article. The first is out of my power, the
latter is too bi..y to use (it says whatever one wants - for at least
an hour).
So exept that?

John W. Kennedy

unread,
Feb 3, 2006, 1:47:18 PM2/3/06
to

Yes, but it makes the semantics of "+" surprising.

Jasen Betts

unread,
Feb 3, 2006, 4:48:55 AM2/3/06
to
On 2006-02-02, Leszek <lesz...@poczta.onet.pl> wrote:
> Hi.

>
> Is it possible in javascript to operate on an array without knowing how mamy
> elements it has?

No it is not because all arrays have a length property which tells you how
many elements they have :)

Bye.
Jasen

Richard Cornford

unread,
Feb 3, 2006, 10:34:02 AM2/3/06
to
Richard Cornford wrote:
<snip>

> The javascript array has no potential to have multiple
> dimensions and so no potential to be 'jagged'. ...
<snip>

As it happens it has just occurred to me that the concept of a
multi-dimensional array can be implemented with a single javascript
Array:-

var a = [];

for(var c = 0;c < 10;++c){
a[c] = a;
}

- The result is a single array that emulates an array with infinite
dimensions. I.E. you can stick as many sets of square brackets and valid
array indexes after the array's Identifier as you want:-

var y = a[0][0][0][0][0][0][0][0][0][0] ... [0][0][0][0][0];

- and still get a valid result from the evaluation of the property
accessor. The resulting object is of course utterly useless as an array,
it will be broken by any attempt to store anything in it, and it is not
(and could not be) 'jagged'. But utterly useless as the result may be it
is one, and the only one, way that a single javascript array can appear
to be multi-dimensional.

Richard.


Thomas 'PointedEars' Lahn

unread,
Feb 3, 2006, 2:53:35 PM2/3/06
to
John W. Kennedy wrote:

> Thomas 'PointedEars' Lahn wrote:
>> John W. Kennedy wrote:
>>> Duncan Booth wrote:
>>>> [...]
>>>> var a = ['a', 'b', 'c'];
>>>> a[4] = 'e'; a[3] = 'd';
>>>> for(var idx in a) {
>>>> alert(idx+"="+a[idx]);

^^^^^^^


>>>> };
>>>>
>>>> The alerts in IE and Firefox go in the order 0,1,2,4,3 (although a
>>>> conforming ecmascript implementation could use any order it fancied).
>>> Note, too, that "idx" above is treated as a string, not an integer.
>> However, this does not matter here. All property names are strings. In
>> fact, any expression as property name is subject to ToString() conversion
>> on property access. See ECMAScript Ed. 3, 11.2.1 and 15.4.
>>
>> This means that the property accesses a["3"] and a[3], and ({3: 33})["3"]
>> and ({3: 33})[3] are equivalent.
>
> Yes, but it makes the semantics of "+" surprising.

I do not see your point, string concatenation always happens with the above
code, and nothing is attempted to be computed. Maybe you are referring to
the following solution for the OP's problem:

var
a = [1, 654, 2, 5, 489, 51, 3851, 681, 32, 5, 0],
sum = 0;

for (var idx in a)
{
sum += a[idx];
}

It also does not matter here whether `idx' refers to an integer (there are
no integers in ECMAScript implementations, all numeric values are IEEE-754
doubles), or to a string value, as it actually does. Note that it is _not_
the indexes that should be added but the array element's values they refer
to.


HTH

PointedEars

Thomas 'PointedEars' Lahn

unread,
Feb 3, 2006, 2:55:43 PM2/3/06
to
Jasen Betts wrote:

Should not that have rather been a "Yes it is because ..." answer? ;-)


PointedEars

VK

unread,
Feb 3, 2006, 3:21:04 PM2/3/06
to

Richard Cornford wrote:
> Richard Cornford wrote:
> <snip>
> > The javascript array has no potential to have multiple
> > dimensions and so no potential to be 'jagged'. ...
> <snip>
>
> As it happens it has just occurred to me that the concept of a
> multi-dimensional array can be implemented with a single javascript
> Array:-
>
> var a = [];
>
> for(var c = 0;c < 10;++c){
> a[c] = a;
> }
>
> - The result is a single array that emulates an array with infinite
> dimensions. I.E. you can stick as many sets of square brackets and valid
> array indexes after the array's Identifier as you want:-
>
> var y = a[0][0][0][0][0][0][0][0][0][0] ... [0][0][0][0][0];

Richard, what's that? And how is it related with dimensions? It's a
single-dimensional array having 10 elements where each element value is
a reference to the containing array.

Richard Cornford

unread,
Feb 3, 2006, 5:21:38 PM2/3/06
to
VK wrote:
> Richard Cornford wrote:
>> Richard Cornford wrote:
>> <snip>
>> > The javascript array has no potential to have multiple
>> > dimensions and so no potential to be 'jagged'. ...
>> <snip>
>>
>> As it happens it has just occurred to me that the concept of a
>> multi-dimensional array can be implemented with a single
>> javascript Array:-
>>
>> var a = [];
>>
>> for(var c = 0;c < 10;++c){
>> a[c] = a;
>> }
>>
>> - The result is a single array that emulates an array with
>> infinite dimensions. I.E. you can stick as many sets of square
>> brackets and valid array indexes after the array's Identifier
>> as you want:-
>>
>> var y = a[0][0][0][0][0][0][0][0][0][0] ... [0][0][0][0][0];
>
> Richard, what's that?

It is what is known as 'intellectual rigor' (look it up).

> And how is it related with dimensions? It's a
> single-dimensional array having 10 elements where each
> element value is a reference to the containing array.

It is an array of arrays that only employs a single javascript array.

An emulation in javascript of what can be achieved with a
multi-dimensional array in languages that have such can only be done
with an array of arrays. Requiring an array of arrays implies that any
emulation of a multi-dimensional array cannot be done with a single
javascript Array object. I have demonstrated that there is a single case
where an array of arrays can be constructed and still only employ a
single javascript Array object.

Utterly useless as this one special case may be it would be dishonest to
deny its existence. Fortunately my deduction was that since an emulation
of what can be done with a 'jagged' array in languages that support such
can only be done with an array of arrays then 'jagged' cannot be an
appropriate term to apply to any single javascript array object, and so
'jaggedness' is not a quality of javascript Arrays. As the one
exceptional case where a single javascript Array object may appear to be
multi-dimensional in no way qualifies as 'jagged' that premise is not
altered by that observation.

Richard.


VK

unread,
Feb 3, 2006, 6:01:40 PM2/3/06
to

Richard Cornford wrote:
> >> var a = [];
> >>
> >> for(var c = 0;c < 10;++c){
> >> a[c] = a;
> >> }
> It is an array of arrays that only employs a single javascript array.

It is not: you have forgotten that in JavaScript arrays (as other
objects) are passed *by reference*. So you've created a rather
interesting (I have to admit it) circular structure where on each loop
you change the a[] array and add new reference on it into a[] itself.
But by the end you still have nothing but references to the same object
in all elements. This is why you cannot make any assignment in this
structure - it would be like to be a spectateur and the main "hero" on
funerals.
Same twist can be done with the associative array as well (with the
same useless outcome) so it is not anyhow related with the array
question.

> An emulation in javascript of what can be achieved with a
> multi-dimensional array in languages that have such can only be done
> with an array of arrays. Requiring an array of arrays implies that any
> emulation of a multi-dimensional array cannot be done with a single
> javascript Array object. I have demonstrated that there is a single case
> where an array of arrays can be constructed and still only employ a
> single javascript Array object.

You are coming from the wrong assumption that multi-dimensional array
and jagged array are in XOR relations for any given language (so either
m-d or jagged but not both). It is not true: in some languages (say C#)
you can operate with both types. So even if you could create a real m-d
array in JavaScript it would not deny per se the jagged nature of the
Array as it is (thus as it's presented by default in the programming
environment).

I have a feeling that you just don't like the term "jagged" as some
low-class name, like it was with "hash". I could propose than another
as well official naming pair by calling m-d array "safe" array and
jagged array "unsafe" array. I'm not going to use it personally:
because m-d and jagged are more common and more "talking", but for this
thread that could be a compromise.

Richard Cornford

unread,
Feb 3, 2006, 7:49:34 PM2/3/06
to
VK wrote:
> Richard Cornford wrote:
>> >> var a = [];
>> >>
>> >> for(var c = 0;c < 10;++c){
>> >> a[c] = a;
>> >> }
>> It is an array of arrays that only employs a single javascript
>> array.
>
> It is not: you have forgotten that in JavaScript arrays (as
> other objects) are passed *by reference*. So you've created
> a rather interesting (I have to admit it) circular structure
> where on each loop you change the a[] array and add new reference
> on it into a[] itself. But by the end you still have nothing but
> references to the same object in all elements.

It was you who introduced the expression 'array of arrays' into this
thread, if you don't want to consider an array of elements that have
values that are references to arrays as an array of arrays then you
should not have introduced the expression into this discussion in the
first place.

> This is why you cannot make any assignment in
> this structure - it would be like to be a spectateur
> and the main "hero" on funerals.

It is not the fact that an array or arrays can only be an array of
references to arrays in javascript that precludes meaningful assignment
to array index properties in this structure. That is a consequence of
all of the references referring to the same array, and if they did not
all refer to the same array then this apparently multi-dimensional
structure would not be constructed of a single javascript Array and so
could not be considered as an exception to proposition that the term
multi-dimensional cannot be applied to a single javascript Array.

> Same twist can be done with the associative array as well
> (with the same useless outcome) so it is not anyhow related
> with the array question.

The 'array question' we are dealing with here is whether the term
'jagged' can be applied as a characteristic of javascript Arrays. That
question has side-tracked through a consideration of whether the term
'multi-dimensional' can be applied as a characteristic of javascript
Arrays.

The original question is answered by pure logic because in javascript:-

IF ('jagged') THEN (NOT a single Array object)

- is a truth, and therefor:-

IF (a single Array object) THEN (NOT 'jagged')

- is also a truth. The singleness of any single javascript array
precludes jaggedness so jaggedness is not a characteristic of javascript
arrays (it can only be a characteristic of javascript structures that
would normally be constructed of multiple (at least 2) arrays).

On the other hand:-

IF (multi-dimensional) THEN (NOT a single Array object)

- is not a truth in javascript as a single javascript Array instance can
demonstrably form a structure that resembles the type of structure
needed to implement multi-dimensionalness sufficiently closely to be
regarded as multi-dimensional itself.

It is certainly not a good idea to characterise javascript arrays as
multi-dimensional, but that characterisation cannot be precluded upon
purely logical grounds in the way the characteristic 'jagged' can.

>> An emulation in javascript of what can be achieved with a
>> multi-dimensional array in languages that have such can
>> only be done with an array of arrays. Requiring an array
>> of arrays implies that any emulation of a multi-dimensional
>> array cannot be done with a single javascript Array object.
>> I have demonstrated that there is a single case where an
>> array of arrays can be constructed and still only employ a
>> single javascript Array object.
>
> You are coming from the wrong assumption that multi-dimensional
> array and jagged array are in XOR relations for any given
> language (so either m-d or jagged but not both).

It is hard for me to say what misconceptions of English and logic have
led you to this wrong, irrelevant and insane conclusion. You really are
utterly out of your depth in any reasoned debate.

> It is not true: in some languages (say C#) you can operate
> with both types. So even if you could create a real m-d array
> in JavaScript it would not deny per se the jagged nature of
> the Array as it is (thus as it's presented by default in the
> programming environment).

It should be so obvious that there is not need to state that for an
array jaggedness pre-supposes multi-dimensionality.

> I have a feeling that you just don't like the term "jagged" ...
<snip>

You are wrong.

Richard.


Thomas 'PointedEars' Lahn

unread,
Feb 3, 2006, 9:01:06 PM2/3/06
to
VK wrote:

> Richard Cornford wrote:
>> >> var a = [];
>> >>
>> >> for(var c = 0;c < 10;++c){
>> >> a[c] = a;
>> >> }
>> It is an array of arrays that only employs a single javascript array.
>
> It is not: you have forgotten that in JavaScript arrays (as other
> objects) are passed *by reference*.

Nonsense.

First, it *is* an array of arrays that only employs a single Array (object).

Second, objects are not passed at all, they merely are created and exist
until they are garbage-collected when they are no longer referred.
References to objects are passed to functions by value, just as any other
value. But here no function call is involved, I wonder what this would
have to do with that (well, in fact I do not wonder really -- it is all
too clear that you have exactly no clue what you are talking about).

> So you've created a rather interesting (I have to admit it) circular
> structure where on each loop you change the a[] array and add new
> reference on it into a[] itself. But by the end you still have nothing but
> references to the same object in all elements.

Richard recognized that already (but of course you have either not read or
not understood his explanations), and that this is the only way a
J(ava)Script/ECMAScript array can be really multi-dimensional. Which was
the whole point of his example.

> This is why you cannot make any assignment in this structure - it would
> be like to be a spectateur and the main "hero" on funerals.

^^^^^^^^^^ Should this be French for "spectator"?

More nonsense. An assignment is entirely possible everywhere within this
structure; the reference to the own Array object would be replaced with the
assigned value. The resulting array would be an array where the element
with the same index as the index of the last property access is replaced
with that value. For example, with

a[1][2][3][0] = 42;

/*
the assignment is evaluated as follows:

0. a[1][2][3][0] = 42;
1. a[2][3][0] = 42; // a[1] === a
2. a[3][0] = 42; // a[2] === a
3. a[0] = 42; // a[3] === a

While

42,,,,,,,,,

is displayed with
*/

window.alert(a);

/*
the real, infinitely recursive (`...'), and therefore programmatically
not displayable data structure is

[
42,
[42, [42, [42, [42, [42, [42, ...], ...], ...], ...], ...], ...]
[...],
[...],
[...],
[...],
[...],
[...],
[...],
[...]
]

(where `[...]' is just a means to say "Array object", not "new Array
object"), as can be showed with
*/

window.alert(a[1]); // a[1] === a[2] === ... === a[9] === a
window.alert(a[1][0]); // a[1][0] === a[0] === 42
window.alert(a[1][1]); // a[1][1] === a[1] === a
window.alert(a[1][1][0]); // a[1][1][0] === a[1][0] === a[0] === 42
window.alert(a[1][2][0]); // a[1][2][0] === a[2][0] === a[0] === 42
// ...
window.alert(a[2]); // a[2] === a[1] === ... === a[9] === a
window.alert(a[2][0]); // a[2][0] === a[0] === 42
window.alert(a[2][1][0]); // a[2][1][0] === a[1][0] === a[0] === 42
// ...
window.alert(a[2][2]); // a[2][2] === a[2] === a
window.alert(a[2][2][0]); // a[2][2][0] === a[2][0] === a[0] === 42

// and so on.


PointedEars

VK

unread,
Feb 4, 2006, 5:43:54 AM2/4/06
to
Who's interested in what I'm answering to please read the whole thread
<http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/046263f60dbb73f0/f3fe79c21622df04#f3fe79c21622df04>


Gentlemen,

That's getting really dangerous for you: in order to prove one wrong
point (that JavaScript Array is not jagged) you had to intriduce a
bounch of new wrong points plus you had to disavow a lot of you
previous statements. It's dangerous because it's a sure way to
transform a discussion into a casuistical match where the only task is
to negate the very last statement of your opponent without relation
with the topic and the previous statements.

In your attempt to dismiss VK you even stated that JavaScript Array is
a whole separate data structure having much more difference from other
structures (like generic Object) than simply length autocounter. At any
other time it would fill my heart with joy, but not now because I see
that it is not an expression of the real believe I'm seeking from you
but a momentary side-effect of your excitement :-)

Questions to be answered:
1) What is multi-dimensional array
2) What is jagged array
3) What is safe and unsafe array and their relations with m-d and j
arrays
4) What is the nature of JavaScript Array

I know the exact answers on each and every of these questions after one
year of careful studies. I still want to give each question not by my
stupid mouth but by some *reputable* *printed* source. It will take
some time (within a week I guess) as I'm mostly on my JSONet project at
my spare time. But I feel it is necessary to move out the discussion
out of the personal opinions into a discussion over some publically
established categories.

I guess it will be more productive.

Lasse Reichstein Nielsen

unread,
Feb 4, 2006, 7:38:26 AM2/4/06
to

I guess the joke could be that it's not possible to operate on an
array without know how many elements it has, because you *do* know how
many elements it has.

(and then we are back at the discussion about whether a unassigned
index less than length counts as an element or not :)
/L
--
Lasse Reichstein Nielsen - l...@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'

Lasse Reichstein Nielsen

unread,
Feb 4, 2006, 7:54:15 AM2/4/06
to
"VK" <school...@yahoo.com> writes:

> Questions to be answered:
> 1) What is multi-dimensional array

It's a vague term. Let's use the C definition, where it is a
rectangular structure of elements, that requires more than one index
to look up the elements. The structure is "rectangular" in that the
range of valid indices on the different index-axes are independent of
eachother.

> 2) What is jagged array

I must guess here, because I haven't heard it before. I'm guessing
that it is a structure where you need more than one index to look up
elements, but where the range of valid values on the secondary (and
later) æs depend on the previous ones.

This is what you get with an array of array references in most
langauges, including C (where references are called pointers), Java
and Javascript.

> 3) What is safe and unsafe array and their relations with m-d and j
> arrays

Have no idea. What are safe and unsafe arrays?

> 4) What is the nature of JavaScript Array

Ah, the old question.

A Javascript array is a special Javascript host object, possibly
created using the Array constructor function, where certain property
names are considered special "array indices", and which has a length
property that is always at least one larger than the largest "array
index" property that the object contains.

This allows you to treat the array object as a sparse array in other
languages, while still using all object properties on it as well.

Thomas 'PointedEars' Lahn

unread,
Feb 4, 2006, 8:19:15 AM2/4/06
to
Lasse Reichstein Nielsen wrote:

> "VK" <school...@yahoo.com> writes:
>> 4) What is the nature of JavaScript Array
>
> Ah, the old question.
>

> A Javascript array is a special Javascript host object, [...]

It is a native object, _not_ a host object.


PointedEars

Richard Cornford

unread,
Feb 4, 2006, 9:47:29 AM2/4/06
to
VK wrote:
> Who's interested in what I'm answering to please read the
> whole thread
> http://groups.google.com/...

What is the point of referring people who are reading this thread to
this thread?

> Gentlemen,
>
> That's getting really dangerous for you:

Dangerous? The only danger is of wasting ones time as your intellectual
arsenal is so deficient that you may never see that the point under
discussion was resolved at the time Randy posted yesterday.

> in order to prove one wrong point (that JavaScript Array is
> not jagged)

Not only is that not one wrong point, it is a point that is so not wrong
that it can be proven logically. The only potential vulnerability of
that proof being someone being able to demonstrate a structure
exhibiting 'jaggedness' created with a single javascript Array instance
(and that looks like an imposibility).

> you had to intriduce a bounch of new wrong points

State one. (Or if it is a bunch state all of them, though attempting to
state one will be sufficient to show that no such 'new wrong points'
have been introduced.).

In fact the ability to assert that:-

IF ('jagged') THEN (NOT a single Array object)

- is a truth in javascript is all that is necessary to prove that the
term 'jagged' cannot characterise a javascript Array (only, possibly,
some javascript structures).

> plus you had to disavow a lot of you previous statements.

State one. (Or if it is a lot state all of them, though attempting to
state one will be sufficient to show that no previous statements have
been disavowed).

> It's dangerous because it's a sure way to transform a discussion
> into a casuistical match where the only task is to negate the
> very last statement of your opponent without relation
> with the topic and the previous statements.

Your poor attempt to apply my "own thesis" to C++ and Java arrays
demonstrated the only likely source of flawed reasoning in this
discussion.

> In your attempt to dismiss VK you even stated that JavaScript
> Array is a whole separate data structure having much more
> difference from other structures (like generic Object) than
> simply length autocounter.

Where? If that has been said you should be able to quote the specific
statment.

> At any other time it would fill my heart with joy, but not
> now because I see that it is not an expression of the real
> believe I'm seeking from you but a momentary side-effect of your
> excitement :-)

More likely you perception of such a statement where none exists is
merely an artefact of your wider misconceptions, incomprehension of
English and general irrationality.

> Questions to be answered:
> 1) What is multi-dimensional array

Something that does not exist in javascript, but can be emulation with a
structure (most directly with an array of arrays).

> 2) What is jagged array

Something that does not exist in javascript, but can be emulation with a
structure (most directly with an array of arrays).

> 3) What is safe and unsafe array and their relations with
> m-d and j arrays

Irrelevant notions that popped out of your mind for no apparent reason,
and with no real purpose.

> 4) What is the nature of JavaScript Array

Whatever else the nature of a javascript Array is it is certainly not in
its nature to be 'jagged'.

> I know the exact answers on each and every of these
> questions after one year of careful studies.

LOL. When you announced last week that one month of studying Mozilla
browsers had taken you from a position of (presumably) not knowing
whether it supports the document.styleSheets collection to concluding
that it does not you made it obvious that for you study actually
increases the falseness of your beliefs. If a month's application of
your perverse mental processes can do that I hate to imagine how wrong
you could be after a year.

It should be obvious that you cannot be the only person studying this
subject and so when you are the _only_ person studying the subject who
ends up believing what your believe about it (and you cannot convince
anyone with any familiarity with the subject that you are correct) it
should be equally obvious that your you are applying a flawed process to
your studies.

> I still want to give each question not by my stupid mouth but
> by some *reputable* *printed* source.

Very few sources of information about javascript are both reputable and
printed.

> It will take some time (within a week I guess) as I'm
> mostly on my JSONet project at my spare time.

I won't be holding my breath. So far whenever you have promised that you
would post some response at a more distant future date you have not done
so (and I was looking forward to you attempting to defend your
misrepresentation of Ockham's razor, but it has not materialised yet).

> But I feel it is necessary to move out the discussion out
> of the personal opinions into a discussion over some
> publically established categories.

The only unsustainable personal opinions being post to this thread have
been posted by you, so if you want to keep the discussion within the
area of reasoned discussion that is entirely at your discretion (though
potentially not within your power).

You should remember that we are on Usenet here. If I were posting what
was perceived as irrational nonsense there would be people posting
follow-ups telling me so. That doesn't appear to be happening, so what
is the best explanation for that?

> I guess it will be more productive.

What I have seen of your "JSONet project" so far falls into the category
of "bizarre and obtuse" so no, it probably won't be more productive
(unless you would otherwise spend the time 'studying'). On the other
hand it probably won't be less productive for you either.

Richard.


Randy Webb

unread,
Feb 4, 2006, 2:01:24 PM2/4/06
to
Jasen Betts said the following on 2/3/2006 4:48 AM:

You sure about that?

<script type="text/javascript">
var myArray = new Array()
myArray['myArrayElement'] = 'something'
alert(myArray.length)
</script>

Randy Webb

unread,
Feb 4, 2006, 2:20:27 PM2/4/06
to
VK said the following on 2/3/2006 1:14 PM:

> Randy Webb wrote:
>> To me, it's not a discussion, it is a one-sided statement from
>> Richard showing the flaws in what you are saying.
>
> And I'm showing the flaws in what he is saying while both are staying
> away from Thomas'-like vocabulary. To me, it is a discussion. ;-)

They aren't flaws though VK. And staying away from Thomas'-like
vocabulary is always admirable.

>> I can answer *any* question not directly related to mutil-dimensional
>> arrays without using any one of those three phrases, and in fact I
>> wouldn't even consider using any of those terms unless it was directly
>> related to the question.
>
> This loud statement is bookmarked too :-)

With regards to Javascript, bookmark it. As of this date, the script
engines on the web do not support, or even know of, a jagged or
multi-dimensional array. Nor do they support a *true* hash array.

>> To date, most of your points of view with regards to Array's has been
>> dead wrong. The funny part is watching you trying to defend that position.
>
> It was confirmed by many, including professional programmers and
> programming specialists.

They have to be JS programmers or JS Specialists as JS is totally
different than any other programming language out there simply because
of the unknown runtime environment.

> As it brings them automatically to the category of "people who knows
no more or even less than VK does":-

Think about what you wrote and anybody falls into the category of
knowing more or less than anybody else does.

> my question would be what authority besides Richard Cornford would you
> accept as an authority?

You are assuming, incorrectly, that I accept Richard as "an authority".
I have had my share of disagreements with Richard as well as other
people in this group. I trust no code until I test it myself, even
Richard's.

But, if I had to choose one person in this group to be "an authority",
it would be - hands down - Martin Honnen. I do not test Martin's code to
see if it works, I test it to tinker with it and learn other things.

Martin reminds of the old TV Commercial in the US. When Martin writes,
people listen.

> I'm really open for requests: except a message form the Lord and
> a wiki article. The first is out of my power, the latter is too
> bi..y to use (it says whatever one wants - for at least an hour).

Wiki's are useless.

> So exept that?

How about something for you to ponder?

Create a multi-dimensional array in JS where no element in that array is
an array.

If JS truly supports multi-dimensional arrays then you should have no
problem creating one for me without making any element in it an array.
And not even Richards example meets that requirement.

Let me know when you figure out that there is no multi-dimensional array
in JS.

VK

unread,
Feb 4, 2006, 3:18:11 PM2/4/06
to

Randy Webb wrote:
> Let me know when you figure out that there is no multi-dimensional array
> in JS.

The whole branch of this thread was that JavaScript array is *not*
multi-dimensional, they are *jagged*. These are two different
categories, and I continuosly stated that JavaScript array is jagged
(see my very first post), not multi-dimensional.

- A is true
- OK, then come back when you understand that A is true

? Who's out of loop here? :-0

I repeat my very first statement: "JavaScript Array is dynamic, jagged,
sparse"

I do not require that everyone in this group will understand this
definition as it requires rather good and specific programming
knowledge. But the fact if some term is not known to me doesn't mean
that the term is wrong or doesn't have sense. It just means that I
don't know something as well as I would like to, is not it?

<quote>
We are using the term "jagged array" to describe a
multi-dimensional array that is
not necessarily rectangular. A two-dimensional "jagged array" can
be thought of as
a vector, each element of which is a vector containing an arbitrary
number of objects.

[] > [] [] [] []
[] > [] [] []
[] > []
[] > [] [] [] []
</quote>

<quote>
The jagged array is basically an array of arrays. So, you one array
could have a length/size of 5 while the next has a size of 3 and the
next 2, and so on. You see the "jagged" part of it? The three would
look a little like this:
1, 2, 3, 4, 5
6, 7, 8
9, 10
Now, you can see that a jagged array can have arrays of different
lengths but in a multi-dimensional array, it is always a perfect
rectangle/cube, no matter what.
</quote>

These are quotes from works published on MIT.edu but I do *not* want to
place them as official references until some more answers I'm waiting
for.

It's just to explain again what I (and real programmers where I'm not
part of) do mean by saying "jagged array". It is cristal clear to
anyone why JavaScript array is jagged and no one ever tried to dismiss
it until this very thread. I'm not sure what your problem is, guys, but
I'm still willing to help, this is why I will bring more 3rd party
explanations and samples later as promised.

Dr John Stockton

unread,
Feb 4, 2006, 2:38:06 PM2/4/06
to
JRS: In article <25ee.43e3...@clunker.homenet>, dated Fri, 3 Feb
2006 09:48:55 remote, seen in news:comp.lang.javascript, Jasen Betts
<ja...@free.net.nz> posted :

But consider the values of L and N after executing

var A = []
A[99999] = 9
L = A.length // 100000
N = 0
for (J in A) N++ // 1

The validity of the *last* of those statements implies that the answer
to the question is "Yes".

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)

VK

unread,
Feb 4, 2006, 5:34:09 PM2/4/06
to

Dr John Stockton wrote:
var A = []
> A[99999] = 9
> L = A.length // 100000
> N = 0
> for (J in A) N++ // 1
>
> The validity of the *last* of those statements implies that the answer
> to the question is "Yes".

"Yes" if you are using Array as Array and do not use it as hashtable
*and* as array *at the same time*. JavaScript is flexible enough for
this (and many more tricks), but they are usable only with a good
understanding of underlaying machanics:- otherwise it's a call for
troubles.

<http://www.geocities.com/schools_ring/ArrayAndHash.html>
Section "Array as hash" explains it in details.


P.S.
var A = new Function();
A[0] = 1;
A[9999] = 2;
for (var p in A) {alert(p);}

You can do a lot of things in JavaScript:- but not everything one can
do one *should* do, especially if the core matter is not clearly
understood.

Randy Webb

unread,
Feb 4, 2006, 9:11:54 PM2/4/06
to
VK said the following on 2/4/2006 3:18 PM:

> Randy Webb wrote:
>> Let me know when you figure out that there is no multi-dimensional array
>> in JS.
>
> The whole branch of this thread was that JavaScript array is *not*
> multi-dimensional, they are *jagged*. These are two different
> categories, and I continuosly stated that JavaScript array is jagged
> (see my very first post), not multi-dimensional.
>

You need to re-look at the sub-thread that this is in. It starts with
Richard replying to you and you replying back about being late and
tired. Read from that point on. I said I could discuss arrays, and
explain them, without referring to "jagged", "multi-dimensional" and a
"hash array". Unless it was related to the question. And the only time I
will ever use those three terms in relation to JS arrays is to say "JS
Arrays do not possess those qualities" because they don't.

> - A is true
> - OK, then come back when you understand that A is true
>
> ? Who's out of loop here? :-0
>
> I repeat my very first statement: "JavaScript Array is dynamic, jagged,
> sparse"
>
> I do not require that everyone in this group will understand this
> definition as it requires rather good and specific programming
> knowledge. But the fact if some term is not known to me doesn't mean
> that the term is wrong or doesn't have sense. It just means that I
> don't know something as well as I would like to, is not it?
>
> <quote>
> We are using the term "jagged array" to describe a
> multi-dimensional array that is
> not necessarily rectangular. A two-dimensional "jagged array" can
> be thought of as
> a vector, each element of which is a vector containing an arbitrary
> number of objects.
>
> [] > [] [] [] []
> [] > [] [] []
> [] > []
> [] > [] [] [] []
> </quote>

Read that first line. In order for an array to be "jagged" then it has
to be multi-dimensional according to your own quote. Since you admitted
that JS doesn't have multi-dimensional arrays then how can it have a
"jagged" array? It can't because in order for an array to be jagged it
has to be multi-dimensional.


> <quote>
> The jagged array is basically an array of arrays. So, you one array
> could have a length/size of 5 while the next has a size of 3 and the
> next 2, and so on. You see the "jagged" part of it? The three would
> look a little like this:
> 1, 2, 3, 4, 5
> 6, 7, 8
> 9, 10
> Now, you can see that a jagged array can have arrays of different
> lengths but in a multi-dimensional array, it is always a perfect
> rectangle/cube, no matter what.
> </quote>
>
> These are quotes from works published on MIT.edu but I do *not* want to
> place them as official references until some more answers I'm waiting
> for.

Do you actually trust your own quotes when they contradict one another?

First quote:

> We are using the term "jagged array" to describe a
> multi-dimensional array that is not necessarily rectangular.

Second quote:

> The jagged array is basically an array of arrays.

Which is it? A multi-dimensional array or an array of arrays? JS can
have the second, it can't have the first.

If the people at MIT can't even figure out what they mean without
contradicting themselves, I will have to remember to stay away from them.

> It's just to explain again what I (and real programmers where I'm not
> part of) do mean by saying "jagged array".

If "real programmers" don't know the difference between a jagged array,
multi-dimensional array and an array of arrays, then please move me to
the amateur column because I don't want to be associated with them.


> It is cristal clear to anyone why JavaScript array is jagged

No, it is crystal clear to anyone who understands JS that JS does not
possess a jagged array.

> and no one ever tried to dismiss it until this very thread.

Probably because this is the first time anybody tried to improperly
apply the term "jagged" to a JS array.

> I'm not sure what your problem is, guys, but I'm still willing to
> help, this is why I will bring more 3rd party explanations and samples
> later as promised.

The major problem is when someone says something that is not true and it
goes uncorrected then it leads to more questions down the road and it is
an effort to correct that incorrectness as early as possible.

Jasen Betts

unread,
Feb 4, 2006, 11:14:42 PM2/4/06
to
On 2006-02-04, Randy Webb <HikksNo...@aol.com> wrote:
> Jasen Betts said the following on 2/3/2006 4:48 AM:
>> On 2006-02-02, Leszek <lesz...@poczta.onet.pl> wrote:
>>> Hi.
>>>
>>> Is it possible in javascript to operate on an array without knowing how mamy
>>> elements it has?
>>
>> No it is not because all arrays have a length property which tells you how
>> many elements they have :)
>
> You sure about that?

That was indeed my intent.

><script type="text/javascript">
> var myArray = new Array()
> myArray['myArrayElement'] = 'something'
> alert(myArray.length)
></script>

you are giving the array a property, not an element.

--

Bye.
Jasen

Dr John Stockton

unread,
Feb 5, 2006, 7:40:12 AM2/5/06
to
JRS: In article <1139092449.5...@f14g2000cwb.googlegroups.com>
, dated Sat, 4 Feb 2006 14:34:09 remote, seen in
news:comp.lang.javascript, VK <school...@yahoo.com> posted :

>
>Dr John Stockton wrote:
> var A = []
>> A[99999] = 9
>> L = A.length // 100000
>> N = 0
>> for (J in A) N++ // 1
>>
>> The validity of the *last* of those statements implies that the answer
>> to the question is "Yes".
>
>"Yes" if you are using Array as Array and do not use it as hashtable
>*and* as array *at the same time*.

An Array is an Array, no matter how it is used.

><http://www.geocities.com/schools_ring/ArrayAndHash.html>
>Section "Array as hash" explains it in details.

Detail is all very well; but correctness is more important.

>P.S.
>var A = new Function();
>A[0] = 1;
>A[9999] = 2;
>for (var p in A) {alert(p);}

Without knowing what you think that shows, meaningful comment is not
possible.

> but not everything one can
>do one *should* do, especially if the core matter is not clearly
>understood.

That includes writing about the matter. You should follow your own
advice in that particular case, although not, of course, in general.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

Dr John Stockton

unread,
Feb 5, 2006, 10:32:46 AM2/5/06
to
JRS: In article <1139084291....@f14g2000cwb.googlegroups.com>,
dated Sat, 4 Feb 2006 12:18:11 remote, seen in

news:comp.lang.javascript, VK <school...@yahoo.com> posted :
>
>I repeat my very first statement: "JavaScript Array is dynamic, jagged,
>sparse"

Since you have a weak understanding of both javascript and English, you
should not pontificate on terminology. You should not even copy
material read elsewhere, since you lack the capability of evaluating its
soundness.

You should concentrate first on learning English (it seems not to be
taught well in your country) and then on understanding javascript.

Richard Cornford

unread,
Feb 5, 2006, 12:39:08 PM2/5/06
to
VK wrote:
> Randy Webb wrote:
<snip>

>> To date, most of your points of view with regards to Array's
>> has been dead wrong. The funny part is watching you trying to
>> defend that position.
>
> It was confirmed by many, including professional programmers
> and programming specialists.

In its current form the second block of text on your page at:-

<http://www.geocities.com/schools_ring/ArrayAndHash.html>

- (under the title "Array and Hash in JavaScript") reads:-

| You can use a notation like arrayObject[-1] to address the last
| element in the array, but it's not a negative index: it's just
| a shortcut of arrayObject[arrayObject.length-1]

- and that statement is false. It is not a question of interpretation or
implementation vagaries, it is simple a statement that is unambiguously
and objectively false. The language specification says that this must
never be true in any ECMAScript implementation, it is not true in any
implementation, and you can see that it is not true by doing no more
than trying it.

No you might feel reassured to find your "points of view with regards to
Array's" "confirmed by many, including professional programmers and
programming specialists" but when those views include the objectively
false it should be obvious that these confirmations are worthless.

> As it brings them automatically to the category of "people
> who knows no more or even less than VK does"

<snip>

Whether these "programming specialists" know more or less than you (or
both?) is irrelevant; if they are confirming statements about javascript
Arrays that are objectively false their opinions about javascript arrays
are worthless.

Richard.


Richard Cornford

unread,
Feb 5, 2006, 12:39:12 PM2/5/06
to
VK wrote:
> Randy Webb wrote:
>> Let me know when you figure out that there is no
>> multi-dimensional array in JS.
>
> The whole branch of this thread was that JavaScript array is
> *not* multi-dimensional, they are *jagged*. These are two
> different categories, and I continuosly stated that JavaScript
> array is jagged (see my very first post), not multi-dimensional.

So you cannot see that jaggedness pre-supposes multi-dimensionality? If
you deny multi-dimensionality you preclude jaggedness. But as I have
said, the only sense in which a single javascript Array can appear
multi-dimensional is when it forms an array of arrays where all the
array references refer to the same single array, and that structure
precludes jaggedness. So either a javascript Array is not
multi-dimensional and so jaggedness is precluded, or you accept the
single apparently multi-dimensional exception and still preclude
jaggedness.

> - A is true
> - OK, then come back when you understand that A is true
>
> ? Who's out of loop here? :-0
>
> I repeat my very first statement: "JavaScript Array is
> dynamic, jagged, sparse"

Repeating something does not make it true.

> I do not require that everyone in this group will understand
> this definition as it requires rather good and specific
> programming knowledge.

Clearly your understanding does not require a good and specific
programming knowledge; it requires and inability to comprehend logic and
a stubborn refusal to perceive personal inadequacies.

> But the fact if some term is not known to me doesn't mean
> that the term is wrong or doesn't have sense. It just means that I
> don't know something as well as I would like to, is not it?
>
> <quote>
> We are using the term "jagged array" to describe a

> multi-dimensional array that is not necessarily rectangular. ...
> </quote>

A javascript Array is not a multi-dimensional array that is not
necessarily rectangular.

> <quote>
> The jagged array is basically an array of arrays. ...
> </quote>

A javascript Array is not an array of arrays.

> These are quotes from works published on MIT.edu but I do
> *not* want to place them as official references until some
> more answers I'm waiting for.

All you are doing is quoting (and without citing0 statements that say
that things that are jagged are not javascript arrays. If you want to
make a credible point here you need to be presenting something that is a
single javascript Array and that exhibits jaggedness.

> It's just to explain again what I (and real programmers where
> I'm not part of) do mean by saying "jagged array".

And so far they appear to mean exclusively things that are not a single
javascript array.

> It is cristal clear to
> anyone why JavaScript array is jagged

Absolutely the reverse. It is crystal clear to everyone except you that
a single javascript Array is completely incapable of exhibiting anything
that might reasonably be described as jaggedness, and so that javascript
arrays are not jagged.

> and no one ever tried to dismiss it until this very thread.

As Randy said, to date nobody has been irrational enough to propose that
javascript Arrays are jagged.

> I'm not sure what your problem is, guys,

We prefer comp.lang.javascirpt to be a source of information about
javascript not of bizarre, uninformed, irrational and false fantasies
about javascript.

> but I'm still willing to help,

Your only possibility is to help yourself, by accepting that the process
that you are applying to your understanding of javascript is so
critically flawed that you know next to nothing now, and less and less
as you attempt to 'study' the subject. You need to significantly change
something before you can even hope to stop being a liability.

> this is why I will bring more 3rd party
> explanations and samples later as promised.

Any number of statements that things that are not javascript Arrays
exhibit jaggedness will not impact the nature of a javascript Array.
They would be a waste of everyone's time.

You either can demonstrate a single javascript Array exhibiting
'jaggedness' or you are wrong, end of story.

Richard.


VK

unread,
Feb 5, 2006, 12:43:13 PM2/5/06
to

Dr John Stockton wrote:
> Since you have a weak understanding of both javascript and English, you
> should not pontificate on terminology. You should not even copy
> material read elsewhere, since you lack the capability of evaluating its
> soundness.
>
> You should concentrate first on learning English (it seems not to be
> taught well in your country) and then on understanding javascript.

Dear Doc,
As it was pointed out already in this thread that you're trying to
participate in a topic which is beyond of your current knowledge. That
was already clearly demostrated by some "advises" you've posted. Please
care to learn the basics before making some global statements.


Respectfully,

... aka VK

Randy Webb

unread,
Feb 6, 2006, 5:17:00 PM2/6/06
to
VK said the following on 2/3/2006 1:14 PM:

> my question would be what authority besides Richard Cornford would you
> accept as an authority?

After just reading your reply to me in another thread, it made me think
about this again and I will give you one more to bookmark, fair enough?

If Richard Cornford, or anybody else for that matter, were to post here
and say that JS has any of the following three things:

1)"multi-dimensional arrays" (which it doesn't)
2)"jagged array" (which it doesn't)
3)"hash array" (which it doesn't)

Then if I am not the first one then I will get in line to tell them they
are wrong.

I will even say that Richard's test code for a multi-dimensional array
doesn't fit the definition I gave you:

<quote>


Create a multi-dimensional array in JS where no element in that array is
an array.

If JS truly supports multi-dimensional arrays then you should have no
problem creating one for me without making any element in it an array.
And not even Richards example meets that requirement.

</quote>

The only thing that will *ever* change that is if the JS engines are
changed to support them.

VK

unread,
Feb 7, 2006, 3:02:53 AM2/7/06
to

Randy Webb wrote:
> After just reading your reply to me in another thread, it made me think
> about this again and I will give you one more to bookmark, fair enough?
>
> If Richard Cornford, or anybody else for that matter, were to post here
> and say that JS has any of the following three things:
>
> 1)"multi-dimensional arrays" (which it doesn't)

True

> 2)"jagged array" (which it doesn't)

Wrong

> 3)"hash array" (which it doesn't)

Wrong (besides there is not "hash array" as a proper term. One should
say "associative array", "hashtable" or "hash")

Let's stop on the first wrong. You are still i) refusing to read the
definition ii) thinking of a particular array instead of the model.

var myArray = new Array();

myArray[0] = new Array(1,2,3,4);
myArray[1] = new Array(1,2,3);
myArray[2] = new Array(1,2);
myArray[3] = new Array(1,2,3,4);

myArray is a sigle-dimension array. But it has other arrays as its
elements. In the programming it is called "jagged array". I
intentionally took different size arrays to show why the word "jagged"
had been chosen. It again doesn't imply that internal arrays *have* to
be of different size. They can perfectly be of the same size. It's
again not a description of a particular instance, but abstract model
thinking: this kind of array *can* be jagged, so it is always called
"jagged" to destinguish from "multi-dimensional" array which cannot be
jagged.

You are welcome to print out myArray sample and go across the world
(both European and American institutes are welcome) asking for
definition and explanation. It will be the same I just gave you.

Thomas 'PointedEars' Lahn

unread,
Feb 7, 2006, 3:54:48 AM2/7/06
to
VK wrote:

> Randy Webb wrote:
>> After just reading your reply to me in another thread, it made me think
>> about this again and I will give you one more to bookmark, fair enough?
>>
>> If Richard Cornford, or anybody else for that matter, were to post here
>> and say that JS has any of the following three things:

>> [...]


>> 2)"jagged array" (which it doesn't)
>
> Wrong

AIUI jagged arrays are possible with ECMAScript implementations, however
it is incorrect to say that ECMAScript-conforming arrays "are jagged" (by
default) as you do:

,-<URL:http://en.wikipedia.org/wiki/Jagged_array>
|
| [...]
| Arrays of arrays, on the other hand, allow the creation of ragged arrays,
| also called jagged arrays, in which the valid range of one index depends
| on the value of another, or in this case, simply that different rows can
| be different sizes.

Just to quote some of the top Google hits for "jagged array":

,-<URL:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vclrfjaggedarrays.asp>
|
| A jagged array is an array whose elements are arrays. The elements of a
| jagged array can be of different dimensions and sizes. A jagged array is
| sometimes called an "array-of-arrays."

,-<URL:http://www.startvbdotnet.com/language/arrays.aspx>
|
| Jagged Arrays
|
| Another type of multidimensional array, Jagged Array, is an array of
| arrays in which the length of each array can differ. Example where this
| array can be used is to create a table in which the number of columns
| differ in each row. Say, if row1 has 3 columns, row2 has 3 columns then
| row3 can have 4 columns, row4 can have 5 columns and so on.

,-<URL:http://www.geekpedia.com/tutorial78_Jagged-arrays.html>
|
| They say a jagged array is an array of arrays.



>> 3)"hash array" (which it doesn't)
>
> Wrong (besides there is not "hash array" as a proper term. One should
> say "associative array", "hashtable" or "hash")

No, one should not. For that would mean that such properties become part of
the encapsulated array data structure, that they are exposed as elements of
the array, which they are not (the Array object's `length' property makes
that perfectly clear). They are only properties of the encapsulating Array
object, which is a different thing.


PointedEars

VK

unread,
Feb 7, 2006, 5:07:50 AM2/7/06
to
Thomas 'PointedEars' Lahn wrote:
> >> 3)"hash array" (which it doesn't)
> >
> > Wrong (besides there is not "hash array" as a proper term. One should
> > say "associative array", "hashtable" or "hash")
>
> No, one should not. For that would mean that such properties become part of
> the encapsulated array data structure, that they are exposed as elements of
> the array, which they are not (the Array object's `length' property makes
> that perfectly clear). They are only properties of the encapsulating Array
> object, which is a different thing.


My "wrong" about "hash array" was in reply to:
...


3)"hash array" (which it doesn't)

...
where I took "it" as a reference to "JavaScript", so "JavaScript
doesn't have hash array", something like that. It is difficult
sometimes to keep the thread of discussion when your opponents are
ready to bring X amount of side topics as soon as they are losing on
the main one. :-) Actually you know that, do you? ;-))

Richard Cornford

unread,
Feb 7, 2006, 7:29:14 PM2/7/06
to
VK wrote:
> Randy Webb wrote:
<snip>
>> ... and say that JS has any of the following three things:

>>
>> 1)"multi-dimensional arrays" (which it doesn't)
>
> True
>
>> 2)"jagged array" (which it doesn't)
>
> Wrong
>
>> 3)"hash array" (which it doesn't)
>
> Wrong

It has been observed that javascript should theoretically be capable of
emulating anything. A reasonable criteria for deciding whether a
language that can emulate anything "has" something specific might be to
examine how that something could be achieved with the language and
distinguish between the things that need to be emulated and those that
do not. With the things that do not need to be emulated being the things
that the language does "have".

None of the items listed above can be employed in javascript without
code being authored in order to emulate them. So javascript does not
"have" any of them.

> (besides there is not "hash array" as a proper term.

It is a bit hypocritical of you to quibbling about terms when you more
often as not use terms in a way that is unique to you.

> One should say "associative array", "hashtable" or "hash")

But one should only use those terms when referring the three distinct
things that are associative arrays, hashtables and hashes. They are
certainly not interchangeable terms for the same thing, and arguably
inapplicable to any native feature of the javascript language.

> Let's stop on the first wrong.

Yes lets. The initial wrong statement you made, and repeated, was:-

| I repeat my very first statement: "JavaScript Array is
| dynamic, jagged, sparse"

There is no question that the javascript Array is dynamic. You can add,
remove and assign new values to the properties of a javascript Array at
any time. All javascript arrays exhibit dynamicness, it is a fundamental
characteristic of the javascript array.

There is no question that the javascript Array is a sparse array. Even
javascript Array instances that are not sparse themselves can be
rendered sparse by deleting some of their 'array index' properties or
assigning bigger values to their - length - property. All javascript
Arrays are capable of exhibiting sparseness, it is a fundamental
characteristic of all javascript Arrays.

But 'jagged' is not an appropriate characteristic to apply to the
javascript array. It is logically impossible for a javascript Array to
exhibit jaggedness, it is _not_ a characteristic of the javascript
array at all.

> You are still i) refusing to read the definition

The definition of what exactly? Would that have been the definitions of
a 'jagged array' that you posted without stating their sources? The
first read:-

| <quote>
| We are using the term "jagged array" to describe a
| multi-dimensional array that is not necessarily rectangular.
| ...

- with a rather contradictory second alternative reading:-

| <quote>
| The jagged array is basically an array of arrays.
| ...

Obviously as javascript Arrays only have a single dimension that first
definition effectively says that a javascript Array is not a 'jagged
array', and as a javascript Array is not an array or array the second
definition states that a javascript array is not a 'jagged array'. So
under those circumstances it is difficult to see what relevance these
definitions have to the question in hand, except to reinforce the
conclusion that it is incorrect to characterise the javascript Array as
'jagged'. A conclusion that requires no reinforcement as it is a logical
consequence of a true statement about javascript, therefor itself true.

> ii) thinking of a particular array instead of the model.

If you want to make a statement about the nature of the javascript Array
the inability to show any javascript array instances exhibiting
jaggedness is a telling factor in deciding whether jaggedness is a
characteristic of the javascript Array. Saying that no javascript Array
instance exhibits jaggedness is not "thinking of a particular array", it
is a general statement about javascript Arrays.

> var myArray = new Array();
> myArray[0] = new Array(1,2,3,4);
> myArray[1] = new Array(1,2,3);
> myArray[2] = new Array(1,2);
> myArray[3] = new Array(1,2,3,4);
>
> myArray is a sigle-dimension array.

As are all javascript Arrays.

> But it has other arrays as its elements.

It certainly does. The structure created here is an array of arrays.

> In the programming it is called "jagged array".

It corresponds with your second quoted definition of a 'jagged array',
and contradicts the first as it is not a multi-dimensional array (except
as an emulation of the multi-dimension concept executed with javascript;
an array of arrays).

> I intentionally took different size arrays to show why
> the word "jagged" had been chosen.

Redundant as that has not been significantly disputed.

> It again doesn't imply that internal arrays *have* to
> be of different size.

They do if you want to call this a 'jagged array'.

> They can perfectly be of the same size.

If they were the same size your could only call this a multi-dimensional
array (as that would be the concept that would be being implemented in
that case, there would be no jaggedness to justify the term 'jagged
array').

> It's again not a description of a particular
> instance, but abstract model

No that is a particular instance. It is an instance of something that
implements the concept of a 'jagged array' as described by the second of
your quoted definitions.

> thinking: this kind of array *can* be jagged, so it is always
> called "jagged" to destinguish from "multi-dimensional" array
> which cannot be jagged.

On the contrary, a 'jagged array' must be a multi-dimensional array. The
first of your quoted definitions stated as much, and the emulation of a
multi-dimensional array in javascript is just as much an array of arrays
as your example of an emulation of a jagged array. The jaggedness of a
jagged array follows from the non-rectangularness of a multi-dimensional
array. With a single dimension there would not be the variation that is
described a jagged, and indeed there would be nothing else to have
variation between.

> You are welcome to print out myArray sample and go
> across the world (both European and American institutes
> are welcome) asking for definition and explanation. It
> will be the same I just gave you.

Your code is already understood, it is just irrelevant to the question
at hand. It is irrelevant because a javascript Array is not an array of
arrays. Choosing to call a particular form of an array of arrays a
'jagged array' does not imply anything about things that are not arrays
of arrays, and the javascript array is not an array of arrays.

The only justification that can be made for "JavaScript Array is
dynamic, jagged, sparse" is to show a (any) javascript Array instance
exhibiting jaggedness (which is a proven impossibility). You can either
do that or your characterisation of javascript Arrays is just false.

Richard.


Jambalaya

unread,
Feb 8, 2006, 2:01:33 PM2/8/06
to
VK wrote:
[snip]

> Let's stop on the first wrong. You are still i) refusing to read the
> definition ii) thinking of a particular array instead of the model.
>
> var myArray = new Array();
> myArray[0] = new Array(1,2,3,4);
> myArray[1] = new Array(1,2,3);
> myArray[2] = new Array(1,2);
> myArray[3] = new Array(1,2,3,4);

It is is you who are refusing to read the spec and are thinking about a
particular array "myArray."

> myArray is a sigle-dimension array. But it has other arrays as its
> elements. In the programming it is called "jagged array".

Array of arrays is more descriptive and accurate terminology. But you
are free to call it whatever you like. Why not just continue with your
own naming scheme and call it a "Psi-array."

> I intentionally took different size arrays to show why the word "jagged"
> had been chosen.

In your example myArray is an array with a length of 4. Each element
contains exactly 1 value. That sounds "rectangular" and "uniform" to
me. Would this array be jagged?

var myArray = ['a', 'abcde', 'abc', 'ab'];

Each element has a different length, so it must be "jagged."

> It again doesn't imply that internal arrays *have* to
> be of different size. They can perfectly be of the same size. It's
> again not a description of a particular instance, but abstract model
> thinking:

Translate "abstract model thinking" to "VK deranged thinking." Herein
lies the root of the problem. Your "thinking" and most other people's
thinking rarely agree.

> this kind of array *can* be jagged, so it is always called
> "jagged" to destinguish from "multi-dimensional" array which cannot be
> jagged.

Javascript has neither m-d nor "jagged" arrays. They can only be
emulated. In your mind you are free to call these emulated constructs
anything you want but that does not mean that javascript natively "has"
these types of constructs.

> You are welcome to print out myArray sample and go across the world
> (both European and American institutes are welcome) asking for
> definition and explanation. It will be the same I just gave you.

I would be very disappointed if I did not get the "array of arrays"
definition in greater quantity than the psi-array definition.
(Unfortunately, this thread (on developersdex.com) is now the top
search result on Google when searching for (javascript "jagged array")
<url:http://www.google.com/search?q=javascript+%22jagged+array%22> so I
fear more people may be exposed to your "abstract model thinking."

VK

unread,
Feb 8, 2006, 4:16:01 PM2/8/06
to

Jambalaya wrote:
> I would be very disappointed if I did not get the "array of arrays"
> definition in greater quantity than the psi-array definition.
> (Unfortunately, this thread (on developersdex.com) is now the top
> search result on Google when searching for (javascript "jagged array")
> <url:http://www.google.com/search?q=javascript+%22jagged+array%22> so I
> fear more people may be exposed to your "abstract model thinking."

And it's great - rather than they read your ... stuff... about
"jaggedness" of single-dimension array containing strings of different
length.

Sure MIT, UC Universities, Microsoft engineers and many others stayed
for years in the dark until Jambalaya brought some light to the
humanity. Sorry for irritation but I hate when someone with no clue on
the matter doesn't hesitate to pull a bunch of proprietary crap freshly
digged from his nose. Sorry.

At least Richard stays for the things he studied *to the deep* himself.
If some conclusions got wrong it's a subject to discuss and correct (if
the willingness is presented). But at least he knows exactly why his
point is right - even if it's really wrong.

FYI: *no one* of terms I used in this thread is coined by myself. I'm
using only terms which are officially accepted in the programming. And
if "jagged array" was used to get Master of Science in MIT then I
humbly suppose that it *is* officially accepted. If "jagged" sounds not
descriptive enough or too slangish it is just too bad. I possibly would
coin something else: but the train is already gone.

Randy Webb

unread,
Feb 9, 2006, 1:39:16 AM2/9/06
to
VK said the following on 2/7/2006 3:02 AM:

> Randy Webb wrote:
>> After just reading your reply to me in another thread, it made me think
>> about this again and I will give you one more to bookmark, fair enough?
>>
>> If Richard Cornford, or anybody else for that matter, were to post here
>> and say that JS has any of the following three things:
>>
>> 1)"multi-dimensional arrays" (which it doesn't)
>
> True
>
>> 2)"jagged array" (which it doesn't)
>
> Wrong

Wrong VK, even by your very own definition.

>> 3)"hash array" (which it doesn't)
>
> Wrong (besides there is not "hash array" as a proper term. One should
> say "associative array", "hashtable" or "hash")

And the same can be said for your "jagged array" then. But in either
event, JS doesn't possess a "hash array", an "associative array" a
"hashtable" nor a "hash".

> Let's stop on the first wrong. You are still i) refusing to read the
> definition ii) thinking of a particular array instead of the model.
>
> var myArray = new Array();
> myArray[0] = new Array(1,2,3,4);
> myArray[1] = new Array(1,2,3);
> myArray[2] = new Array(1,2);
> myArray[3] = new Array(1,2,3,4);
>
> myArray is a sigle-dimension array. But it has other arrays as its
> elements.

That makes it an "array of arrays" and your very first definition of a
"jagged array" that you quoted said a jagged array was a
multi-dimensional array. Which is it? An array of arrays or a
multi-dimensional array?

But, myArray is linear and a linear array can not be jagged.

> In the programming it is called "jagged array".

In *most* programming languages it may be, but not in Javascript my
friend. You are welcome to come up with an MSDN, A Devedge, or an ECMA
page to show me differently though.

> I intentionally took different size arrays to show why the word "jagged"
> had been chosen.

I already knew what it was called "jagged" and to display "jagged"
behavior, to me, it has to be multi-dimensional which JS can't have.

> It again doesn't imply that internal arrays *have* to
> be of different size. They can perfectly be of the same size. It's
> again not a description of a particular instance, but abstract model
> thinking: this kind of array *can* be jagged, so it is always called
> "jagged" to destinguish from "multi-dimensional" array which cannot be
> jagged.
>
> You are welcome to print out myArray sample and go across the world
> (both European and American institutes are welcome) asking for
> definition and explanation. It will be the same I just gave you.

The best Javascript writers on the planet post here. Hands down. Does it
not make you wonder why nobody but VK thinks that JS has a jagged array?

VK

unread,
Feb 9, 2006, 2:18:53 AM2/9/06
to

Randy Webb wrote:
> The best Javascript writers on the planet post here.

A bit too loud to say maybe, but let's us assume it's true :-)

> Hands down. Does it
> not make you wonder why nobody but VK thinks that JS has a jagged array?

Because VK is up to date the best specialist of *JavaScript arrays* on
the planet (if we decided do go by loud definitions).

btw in the reality it's just the opposite: currently Randy and Robert
are the only known people on the planet denying that JavaScript array
is jagged. (I'm not counting few amateurs posted here just for the hell
of nastiness).

RobG

unread,
Feb 9, 2006, 2:19:24 AM2/9/06
to
VK wrote:
[...]

>
> FYI: *no one* of terms I used in this thread is coined by myself. I'm
> using only terms which are officially accepted in the programming. And
> if "jagged array" was used to get Master of Science in MIT then I
> humbly suppose that it *is* officially accepted. If "jagged" sounds not
> descriptive enough or too slangish it is just too bad. I possibly would
> coin something else: but the train is already gone.

No one is disputing what is meant by the term "jagged array is", but
that there is no such native JavaScript object.

Sure you can create an array of arrays using JavaScript Array objects
which emulates a multi-dimensional array that might also be jagged: but
that does not mean JavaScript Arrays are jagged.

Indeed, since they are one-dimensional, they can't possibly be jagged by
your own definition (otherwise you wouldn't need to use an array of
JavaScript Array objects to emulate jaggedness).


--
Rob

RobG

unread,
Feb 9, 2006, 2:26:23 AM2/9/06
to
Richard Cornford wrote:
> Richard Cornford wrote:
> <snip>
>
>>The javascript array has no potential to have multiple
>>dimensions and so no potential to be 'jagged'. ...
>
> <snip>
>
> As it happens it has just occurred to me that the concept of a
> multi-dimensional array can be implemented with a single javascript
> Array:-
>
> var a = [];
>
> for(var c = 0;c < 10;++c){
> a[c] = a;
> }
>
> - The result is a single array that emulates an array with infinite
> dimensions. I.E. you can stick as many sets of square brackets and valid
> array indexes after the array's Identifier as you want:-
>
> var y = a[0][0][0][0][0][0][0][0][0][0] ... [0][0][0][0][0];
>
> - and still get a valid result from the evaluation of the property
> accessor. The resulting object is of course utterly useless as an array,
> it will be broken by any attempt to store anything in it, and it is not
> (and could not be) 'jagged'. But utterly useless as the result may be it
> is one, and the only one, way that a single javascript array can appear
> to be multi-dimensional.

I believe such a case is frequently called the 'trivial solution'. :-)

Maybe it should be called the 'Oozle Woozle Array' after the mythical
Oozle Woozle Bird - so long and thanks for the giggle!


--
Rob

Richard Cornford

unread,
Feb 9, 2006, 3:38:16 AM2/9/06
to
VK wrote:
> Randy Webb wrote:
>> The best Javascript writers on the planet post here.
>
> A bit too loud to say maybe, but let's us assume it's true :-)
>
>> Hands down. Does it not make you wonder why nobody
>> but VK thinks that JS has a jagged array?
>
> Because VK is up to date the best specialist of *JavaScript
> arrays* on the planet (if we decided do go by loud
> definitions).

In your page at:-

<http://www.geocities.com/schools_ring/ArrayAndHash.html>

- (under the title "Array and Hash in JavaScript") your wrote:-

| You can use a notation like arrayObject[-1] to address the last
| element in the array, but it's not a negative index: it's just
| a shortcut of arrayObject[arrayObject.length-1]

- That statement is objectively false, and can be seen to be false by
doing no more than trying it. It is not credible to suppose that the
"best specialist of *JavaScript arrays* on the planet" would make (and
be publishing) statements that are so unambiguously false. In reality
your understanding of javascript arrays is poor; a cloud of superficial
perceptions, misconceptions, irrelevant associations and falsehoods.

The main factor standing in the way of your achieving any real
understanding of the subject is your absolute conviction that you alone
are right and everyone else wrong. A belief that is not even undermined
when it is made clear to you that your are (repeatedly) making false
stamens about javascript generally and javascript arrays in particular.
That, combined with your inability to understand and employ logic, is
more suggestive of mental illness than it is of expertise.

> btw in the reality it's just the opposite: currently Randy
> and Robert are the only known people on the planet denying
> that JavaScript array is jagged.

When did the absence of people actively denying something make it true?
It has been a vary long time since anyone bothered to deny that the sun
goes around the earth, that doesn't mean it does.

Is it really necessary for every contributor to the group to line up and
explicitly tell you that your are wrong? In reality their silence in
response to the posts that are disagreeing with your position is a
statement of the general position. Everyone knows that you are wrong,
and is probably finding it difficult to understand why you are incapable
of seeing that.

> (I'm not counting few amateurs posted here just for the
> hell of nastiness).

So you can post a mixture of lies and nonsense to Usenet but want to
label others 'amateurs'? Remember that over the last month you have
asserted that a method call must be written on a single line of source
code, used a - return null; - statement in a function that could only be
meaningfully used as a constructor and written - void - as the leftmost
token in an expression statement. Your javascript understanding is poor,
and your application of it is amateurish.

Richard.


VK

unread,
Feb 9, 2006, 4:01:43 AM2/9/06
to

Richard Cornford wrote:
> In your page at:-
>
> <http://www.geocities.com/schools_ring/ArrayAndHash.html>
>
> - (under the title "Array and Hash in JavaScript") your wrote:-
>
> | You can use a notation like arrayObject[-1] to address the last
> | element in the array, but it's not a negative index: it's just
> | a shortcut of arrayObject[arrayObject.length-1]

You must be using an outdated copy of my article. The quoted statement
has been made in the version 2.0 ( July 2005 ). It was pointed out by
Lasse Reichstein Nielsen and same day (July 07 2005) corrected. See
details at:
<http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/c12423afa53a28f8/5d5d9f14b0ba09c9#5d5d9f14b0ba09c9>

Indeed "negative index shorcut" is allowed only in array methods (like
slice and splice) but not for addressing elements in the array itself.

Everyone can make a mistake - the task to correct it in a timely
manner. :-)

To make sure that your knowledge about JavaScript arrays is correct,
always use the *official* version of "Array and Hash" article:

<http://www.geocities.com/schools_ring/ArrayAndHash.html>

Randy Webb

unread,
Feb 9, 2006, 4:03:59 AM2/9/06
to
VK said the following on 2/9/2006 2:18 AM:

> Randy Webb wrote:
>> The best Javascript writers on the planet post here.
>
> A bit too loud to say maybe, but let's us assume it's true :-)

It is, even if you don't admit it.

>> Hands down. Does it
>> not make you wonder why nobody but VK thinks that JS has a jagged array?
>
> Because VK is up to date the best specialist of *JavaScript arrays* on
> the planet (if we decided do go by loud definitions).

I want some of what ever you are smoking because it is some good stuff man.

But please tell me, oh great Javascript Array specialist that you claim
to be, how can something that is linear in form be "jagged"? Even your
own quotes (that you have refused, to date, to give URL's to) don't even
agree on what a jagged array is. Thomas gave you the best resources you
could possibly have used in your defense but you missed them.

> btw in the reality it's just the opposite: currently Randy and Robert
> are the only known people on the planet denying that JavaScript array
> is jagged. (I'm not counting few amateurs posted here just for the hell
> of nastiness).
>

Here's your chance then, oh "Great Javascript Array Guru" that you
portray yourself as. Please answer a question for me? It shouldn't be
too hard for you since you claim to be the best JS Array specialist around:

Question:
Why does Richard's code *not* qualify as a multi-dimensional array?

If you are so great, that should take you about .00000000002 seconds to
answer.

VK

unread,
Feb 9, 2006, 4:38:49 AM2/9/06
to

Randy Webb wrote:
> I want some of what ever you are smoking because it is some good stuff man.

Only natural stuff man: a bit of beer and 40 (and counting) posts in
the row from frequent posters like in this thread. LSD takes a rest
after that.


> But please tell me, oh great Javascript Array specialist that you claim
> to be, how can something that is linear in form be "jagged"? Even your
> own quotes (that you have refused, to date, to give URL's to) don't even
> agree on what a jagged array is. Thomas gave you the best resources you
> could possibly have used in your defense but you missed them.

Nothing helpful I can do for you besides copy my sample again:

var myArray = new Array();
myArray[0] = new Array(1,2,3,4);
myArray[1] = new Array(1,2,3);
myArray[2] = new Array(1,2);
myArray[3] = new Array(1,2,3,4);

Maybe it will be a bit more visual:

var myArray = [
[1,2,3,4],
[1,2,3],
[1.2],
[1,2,3,4]
];

If you still do not see why the term "jagged" has been coined then I'm
really out of further ideas. That maybe not the best term to use, but
not always the best terms are going into programming vocabulary.

To foreign readers:
jagged
1. raggedly notched; sharply irregular on the surface or at the
borders.
(Random House Webster, 1998, New York)

To British readers:
The word "jagged" in the above indicated meaning is first registered
in English manuscripts at the beginning of XV century.
(In case if someone thinks of it as a yaky Americanism)

> Here's your chance then, oh "Great Javascript Array Guru" that you
> portray yourself as. Please answer a question for me? It shouldn't be
> too hard for you since you claim to be the best JS Array specialist around:
>
> Question:
> Why does Richard's code *not* qualify as a multi-dimensional array?
>
> If you are so great, that should take you about .00000000002 seconds to
> answer.

Maybe not so quick - my neuron signals are not going so quick (speed of
light limitation, damn it), plus give me a break for typing :-)

Actually it was already answered right away why it is *not*
multi-dimensional array. But as I got more experience in having a
discussion with you, I'm not failing on this trick again. First of all,
dear Sir, you have to find out what *is* multi-dimensional array and
paste (or link) a working sample of multi-dimensional array, say
VBScript, C#, C++ or Java. And this has to come not from your own mind
or a freshly updated wiki article, but *at least* from an engine
producer page or (best of all) from some reputable higher education
establishment.

Asking for definition while refusing to disclose your own one (so you
can always say: "That's not one!") *was* a great trick, but it is
currently explored to the end - with me at least.

Richard Cornford

unread,
Feb 9, 2006, 4:56:50 AM2/9/06
to
VK wrote:
> Richard Cornford wrote:
>> In your page at:-
>>
>> <http://www.geocities.com/schools_ring/ArrayAndHash.html>
>>
>> - (under the title "Array and Hash in JavaScript") your
>> wrote:-
>>
>> | You can use a notation like arrayObject[-1] to address
>> | the last element in the array, but it's not a negative
>> | index: it's just a shortcut of
>> | arrayObject[arrayObject.length-1]
>
> You must be using an outdated copy of my article. The quoted
> statement has been made in the version 2.0 ( July 2005 ).

I accessed your page with that content on 2006-02-04, I would not have
quoted it if I had not first verified the current state of the page.
Claiming that you fixed it 6 months ago is not credible as there is no
way that an HTTP cache stored and delivered a 6 month old version of
such an obscure page.

I noticed when I looked at that page that about 50% of the contend had
disappeared since the last time I looked at your page, so the content
was significantly less false than the original. There isn't going to be
a great deal left once you have removed the remaining irrelevancies,
misconceptions and falsehoods. ;)

<snip>


> Everyone can make a mistake - the task to correct it
> in a timely manner. :-)

Everyone can make mistakes, it takes a fool to repeat them.

> To make sure that your knowledge about JavaScript arrays
> is correct,

There is nothing that you could teach me about javascript arrays, and
your page is more likely to promoted confusion and misunderstanding than
knowledge.

> always use the *official* version of "Array
> and Hash" article:

<snip>

So have you changed the title?

Richard.


VK

unread,
Feb 9, 2006, 5:12:22 AM2/9/06
to

Richard Cornford wrote:
> I accessed your page with that content on 2006-02-04, I would not have
> quoted it if I had not first verified the current state of the page.

Are you publically accusing me in cheating? That's not nice of you. The
relevant paragraph has been corrected July 7 2005. You could not get
not-corrected variant as of 2006-02-04 unless something is deeply wrong
with your server cach.

> Claiming that you fixed it 6 months ago is not credible as there is no
> way that an HTTP cache stored and delivered a 6 month old version of
> such an obscure page.

<http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/c12423afa53a28f8/5d5d9f14b0ba09c9#5d5d9f14b0ba09c9>
Jul 7 2005, 3:36 pm
Lasse Reichstein Nielsen wrote:
> Comment: "You can use a notation like arrayObject[-1] top address the
> last element in the array". Nope, doesn't work. It merely tries to
> access the property named "-1", which doesn't exist unless you created
> it.

VK:
My bad! Did not check it for addressing option. Changed to:

Although in array methods you may refer the last array element using
-1, it's not a negative index, it's just a shortcut: for instance
arrayObject.slice(10,-1) simply means
arrayObject.slice(10,arrayObject.length-1)

P.S. Richard, that's getting too low for a *discussion*. Should we take
a coffee break for a day or two to let emotions out?

Richard Cornford

unread,
Feb 9, 2006, 7:12:25 PM2/9/06
to
VK wrote:
> Randy Webb wrote:
<snip>

>> But please tell me, oh great Javascript Array specialist
>> that you claim to be, how can something that is linear
>> in form be "jagged"?
<snip>

>
> Nothing helpful I can do for you besides copy my sample
> again:
>
> var myArray = new Array();
<snip; irrelevance>

> ];
>
> If you still do not see why the term "jagged" has been
> coined then I'm really out of further ideas.

The reason for using the term 'jagged' (or the alternative 'ragged') has
never been questioned. This thread exists because when you said (and
repeated) "JavaScript Array is dynamic, jagged, sparse" you were
applying the term 'jagged' to something that is incapable of exhibiting
jaggedness; the javascript Array.

No amount of definitions of a 'jagged array' that effectively state that
a jagged array is something that a javascript Array is not will make the
term applicable to a javascript Array. And no number of examples of code
that can be described as a 'jagged array' but represent structures that
are not a javascript Array will convince anyone (except you) either.
Most people don't make the mistake of trying to transfer the qualities
of a construction onto its component parts.

Consider the implications of this notion of transferring a label for a
structure (no matter how appropriate that label may appear for that
structure) to its building blocks. By analogy, and using an archetypal
building block; the house brick: A house brick might be characterised as
'a normally rectangular block of ceramic', and it may be used to build
various sorts of structures, one of which might be appropriately
labelled 'a perimeter barrier around a property' (i.e. a garden wall).

The same logic that labels an array of arrays as a 'jagged array' and
then uses that to justify 'jagged' in "JavaScript Array is dynamic,
jagged, sparse" would also have a house brick characterised as 'a
normally rectangular block of ceramic, a perimeter barrier around
property'. This is not sound reasoning. When component parts are
distinct form the construction the ability to make the construction does
not imbue the components with the qualities of that construction.

And this style of reasoning is doubly poor because the same components
can be used to construct many things for which mutually exclusive labels
are appropriate. This is true of house bricks, which might be used to
create structures that may be labelled 'internal walls', 'paving' and so
on. The house brick could not have all of these qualities at the same
time. And this is particularly true of objects in a programming language
that is capable of emulating anything. Would it be reasonable to
characterise the javascript Object as 'a dynamic collection of
name/value pairs, interface to web services and an XML parser' because
it is possible to use it to create structures that could reasonably be
labelled 'an interface to web services' or an 'XML parser'? Obviously
not.

If you are going to characterise a javascript Array you should be saying
something that is true of javascript Arrays. Either true of all
javascript Arrays or potentially true of all javascript Arrays, and it
is impossible for any javascript Array to exhibit jaggedness so the term
'jagged cannot be appropriately used to characterise javascript Arrays.

This is the crux of the question of the appropriateness of 'jagged' as a
characterisation of the javascript Array; either a (any) javascript
Array instance can be shown to exhibit jaggedness or the term is not
applicable. And as the impossibility of a javascript Array exhibiting
jaggedness has been logically proven nothing short of code demonstrating
this 'impossible phenomenon' would modify the obvious conclusion that
you are incorrect to attempt to apply the tem 'jagged' as a
characterisation of the javascript Array.

> That maybe not the best term to use, but
> not always the best terms are going into
> programming vocabulary.

How appropriate the term may be for an array of arrays is not relevant
when characterising something that is not an array of arrays.

> To foreign readers:
> jagged
> 1. raggedly notched; sharply irregular on the surface
> or at the borders.
> (Random House Webster, 1998, New York)

<snip>

And Randy's question was "how can something that is linear in form be
"jagged"?". We are agreed that the javascript array is not
multi-dimensional and presumably agree that it has a dimension, so it
must have just one dimension. Anything that has just one dimension can
reasonable be described as 'linear', but a straight line does not have a
sharply irregular surface or borders. So how can the single dimensional
javascript array be reasonably characterised as 'jagged'?

>> Question:
>> Why does Richard's code *not* qualify as a
>> multi-dimensional array?

<snip>


> Actually it was already answered right away why it
> is *not* multi-dimensional array.

<snip>

Someone wanting to label the structure that is an array of differently
sized arrays as a 'jagged array' should be able to state a good reason
when they don't what to label an array of identically sized arrays as a
multi-dimensional array. So far you have never made such a statment.

Recall that one of the definitions of a 'jagged array' that you posted
read; "We are using the term "jagged array" to describe a
multi-dimensional array that is not necessarily rectangular", and if a
'jagged array' is an array of arrays and a 'jagged array' is a
multi-dimensional array that is not necessarily rectangular it is
difficult to see how an array of arrays can avoid being labelled a
multi-dimensional array by these definitions of a 'jagged array'.

Richard.


Richard Cornford

unread,
Feb 9, 2006, 7:12:30 PM2/9/06
to
VK wrote:
> Richard Cornford wrote:
>> I accessed your page with that content on 2006-02-04,
>> I would not have quoted it if I had not first verified
>> the current state of the page.
>
> Are you publically accusing me in cheating?

Are you accusing me of lying?

> That's not nice of you.

Ditto.

> The relevant paragraph has been corrected July 7 2005.
> You could not get not-corrected variant as of
> 2006-02-04 unless something is deeply wrong with your
> server cach.

<snip>

Unexpected HTTP caching behaviour is certainly one explanation for the
events that transpired.

It makes no real difference. In your self-proclaimed role as "the best
specialist of *JavaScript arrays* on the planet" you still wrote those
lines, and needed to be told by a lesser mortal that they were nonsense.

Of course all the other lesser mortals who pointed out the flaws in the
aspects of your page that remain were just as correct in their
assessment, you just prefer not to listen to what they had to say.

Richard.


VK

unread,
Feb 9, 2006, 8:00:10 PM2/9/06
to

Richard Cornford wrote:
> VK wrote:
> > Richard Cornford wrote:
> >> I accessed your page with that content on 2006-02-04,
> >> I would not have quoted it if I had not first verified
> >> the current state of the page.
> >
> > Are you publically accusing me in cheating?
>
> Are you accusing me of lying?
>
> > That's not nice of you.
>
> Ditto.
>
> > The relevant paragraph has been corrected July 7 2005.
> > You could not get not-corrected variant as of
> > 2006-02-04 unless something is deeply wrong with your
> > server cach.
> <snip>
>
> Unexpected HTTP caching behaviour is certainly one explanation for the
> events that transpired.

ASK

> It makes no real difference. In your self-proclaimed role as "the best
> specialist of *JavaScript arrays* on the planet" you still wrote those
> lines, and needed to be told by a lesser mortal that they were nonsense.

Yes: *6 months ago*. And they were not some complete out-off-head
nonsense as you may notice. "Negative index shortcut" does exists - but
in array methods. It was a wrong extension of its usage. And 6 month
later "negative index shortcut" is even in standard Collection
addressing schema: insertRow(-1)

So it's nothing like "jagged because it contains links of different
length" and other Of Kings And Cabbage stuff posted here over the last
48 hrs by different people.

> Of course all the other lesser mortals who pointed out the flaws in the
> aspects of your page that remain were just as correct in their
> assessment, you just prefer not to listen to what they had to say.

Whatever was pointed out and appeared to be my mistakes was immediately
corrected. You even may notice thank you notice to Lasse Reichstein
Nielsen at the bottom of my article with disclosure of his personal
position. And the date by the way.

Richard Cornford

unread,
Feb 9, 2006, 8:41:49 PM2/9/06
to
VK wrote:
> Richard Cornford wrote:
<snip>
>> Unexpected HTTP caching behaviour is certainly one
>> explanation for the events that transpired.
>
> ASK

Ask who exactly? The number, nature, disposition and ownership of HTTP
caches along the path of any particular HTTP request is unknowable.

>> It makes no real difference. In your self-proclaimed role
>> as "the best specialist of *JavaScript arrays* on the
>> planet" you still wrote those lines, and needed to be
>> told by a lesser mortal that they were nonsense.
>
> Yes: *6 months ago*.

So 6 months ago you were not the self-proclaimed "the best specialist of
*JavaScript arrays* on the planet"? And what exactly has changed in the
intervening period?

> And they were not some complete out-off-head
> nonsense as you may notice.

Just an objectively false statement.

<snip>


> So it's nothing like "jagged because it contains links
> of different length" and other Of Kings And Cabbage stuff
> posted here over the last 48 hrs by different people.

Is that intended to mean something?

>> Of course all the other lesser mortals who pointed out
>> the flaws in the aspects of your page that remain were
>> just as correct in their assessment, you just prefer not
>> to listen to what they had to say.
>
> Whatever was pointed out and appeared to be my mistakes
> was immediately corrected.

<snip>

Which suffers from your misguided filtering out of what appears (or at
the time appeared) to you not to be mistaken.

Richard.


VK

unread,
Feb 10, 2006, 5:45:43 AM2/10/06
to

Richard Cornford wrote:
> VK wrote:
> > Richard Cornford wrote:
> <snip>
> >> Unexpected HTTP caching behaviour is certainly one
> >> explanation for the events that transpired.
> >
> > ASK
>
> Ask who exactly? The number, nature, disposition and ownership of HTTP
> caches along the path of any particular HTTP request is unknowable.

ASKnowledged

Means we just stop at this point w/o making me to request official
digitally signed FTP log from Yahoo, ICANN IP mapping for each session,
my provider IP mapping to ICANN mapping etc. etc. It's a whole bunch of
paper work from my part and it takes up to 6 months if not expedited. I
already had to pass it once but at least for my clients and at least
for some money involving copyright question. It is easier to blame on
cache really :-))

> >> It makes no real difference. In your self-proclaimed role
> >> as "the best specialist of *JavaScript arrays* on the
> >> planet" you still wrote those lines, and needed to be
> >> told by a lesser mortal that they were nonsense.
> >
> > Yes: *6 months ago*.
>
> So 6 months ago you were not the self-proclaimed "the best specialist of
> *JavaScript arrays* on the planet"? And what exactly has changed in the
> intervening period?

A lot of study.
Also please note that "the best specialist of *JavaScript arrays* on
the planet" had been used in the polemic context of "the best
JavaScript writers in the world in this group" which was said first and
not by me.

> > So it's nothing like "jagged because it contains links
> > of different length" and other Of Kings And Cabbage stuff
> > posted here over the last 48 hrs by different people.
>
> Is that intended to mean something?

It means when when I answered OP's question using proper academically
correct terms, I had to vaste my time and patience to answer on a bunch
of mostly irrelevant posts of kind of "Prove that the Earth is
rounded", "And now prove that the sky is blue" etc.

If something is not as you taught and thought of it to be, what VK has
to do with it? Go unleash you frustration on the first available wiki
(or two), not on me.

> Which suffers from your misguided filtering out of what appears (or at
> the time appeared) to you not to be mistaken.

This is why I checked myself over different reputable sources to make
sure that my "mental filters" do not filter out something important.

Personal "mental filters" check is an important thing everyone needs to
make on a not so frequent but regular basis.

Thomas 'PointedEars' Lahn

unread,
Feb 10, 2006, 9:04:39 AM2/10/06
to
VK wrote:

> Richard Cornford wrote:
>> VK wrote:
>> > Richard Cornford wrote:
>> <snip>
>> >> Unexpected HTTP caching behaviour is certainly one
>> >> explanation for the events that transpired.
>> >
>> > ASK

>> Ask who exactly? [...]
>
> ASKnowledged
> [...]

<URL:http://foldoc.org/?query=ASK>
<URL:http://foldoc.org/?query=ACK>
<URL:http://www.catb.org/~esr/jargon/html/A/ACK.html>


HTH

PointedEars

John G Harris

unread,
Feb 10, 2006, 4:33:58 PM2/10/06
to
In article <1139469533....@z14g2000cwz.googlegroups.com>, VK
<school...@yahoo.com> writes

It was an amateur who invented the photon. He got a Nobel Prize for it.
In English, amateur doesn't mean ignorant, it means someone who doesn't
get paid for it.

Coming back to the subject, the best that a javascript Array object can
do is to hold an array of references. If they are references to Array
objects then the programmer, with considerable effort, has implemented a
structure that has the behaviour of an n-dimensional array. The
structure might be jagged or it might never be - whichever the
programmer's code forces it to be.

The programmer might be building something else. I very much doubt if
your MIT people would use the word jagged when some points are two
dimensional and other points are five dimensional. They'd call it a
tree. (Or a forest, depending where they start from).

John

PS You're not forced to use Array objects to implement a forest/tree.
--
John Harris

VK

unread,
Feb 11, 2006, 5:22:41 AM2/11/06
to

John G Harris wrote:
> It was an amateur who invented the photon. He got a Nobel Prize for it.
> In English, amateur doesn't mean ignorant, it means someone who doesn't
> get paid for it.

Right. Sorry.

> Coming back to the subject, the best that a javascript Array object can
> do is to hold an array of references. If they are references to Array
> objects then the programmer, with considerable effort, has implemented a
> structure that has the behaviour of an n-dimensional array. The
> structure might be jagged or it might never be - whichever the
> programmer's code forces it to be.

As well as array can be sparse or "condensed". A presence of some
feature doesn't imply the necessity to use this feature on practice. At
the same time this feature can be used for the abstract model
description in order to distinguish it from another model.

We say "prototype-based" but it doesn't imply prototype usage:

<script type="text/javascript">
var a = 2;
var b = a + 2;
</script>

No one proposed (yet?) to define JavaScript as "just simply programming
language - and prototype-based if prototypes are used". :-)

P.S. If I was the president of some Programming Entities Naming
Committee I would not endorse "jagged" term. I would try to find
something better. But I'm just using what was named before me.
"static" modifier name is neither good not correct in application to
its effect. But it was named this way before me, so I have no
opportunity to use say "singleized" instead.

ron.h...@gmail.com

unread,
Feb 11, 2006, 11:28:50 PM2/11/06
to
VK wrote:
> John G Harris wrote:
> > It was an amateur who invented the photon. He got a Nobel Prize for it.
> > In English, amateur doesn't mean ignorant, it means someone who doesn't
> > get paid for it.
>
> Right. Sorry.
>

Realy gotta love ya VK! When you're wrong, you insist you are right.
When in one of the seemingly less common instances you are right,
you're readily buffaloed.

The above definition of 'amateur' may be original, but it's not
comprehensive. A number of dictionaries, including the compact OED,
provide any of "incompetent", "inept", "non-professional", and
"lacking professional skill" as valid alternative meanings.

../rh

VK

unread,
Feb 12, 2006, 3:40:04 AM2/12/06
to

ron.h...@gmail.com wrote:
> VK wrote:
> > John G Harris wrote:
> > > It was an amateur who invented the photon. He got a Nobel Prize for it.
> > > In English, amateur doesn't mean ignorant, it means someone who doesn't
> > > get paid for it.
> >
> > Right. Sorry.
> >
>
> Realy gotta love ya VK! When you're wrong, you insist you are right.
> When in one of the seemingly less common instances you are right,
> you're readily buffaloed.

I'm readily agree when I'm wrong in any matter, small or big... as soon
as it is pointed to the correct explanation. Moreover I feel graceful
for being taught something I did not know. I do not agree to be wrong
just because someone says "You ignorant, that's wrong because I says
so". Such arguments do not work for me. And if you read this thread
once over you will see that 95% of posts are of this exact nature.

> The above definition of 'amateur' may be original, but it's not
> comprehensive. A number of dictionaries, including the compact OED,
> provide any of "incompetent", "inept", "non-professional", and
> "lacking professional skill" as valid alternative meanings.

Still the *first* meaning in all distionaries I can hold on is like "a
person who engages in a study, sport, or other activity for pleasure
rather than for financial benefits".

I used it in the additional meaning of "a person inexperienced or
unskilled in a particular activity". I still sorry for using it as such
response drops me down to the level of some of my opponents.

Richard Cornford

unread,
Feb 12, 2006, 9:09:55 AM2/12/06
to
VK wrote:
<snip>

> As well as array can be sparse or "condensed". A presence
> of some feature doesn't imply the necessity to use this
> feature on practice.

The total absence of any evidence of any javascript Array instances
exhibiting jaggedness, plus the logical proof that it is impossible for
a javascript Array instance to exhibit jaggedness, does imply that
'jagged' is an inappropriate term to apply to javascript Arrays.

<snip>


> P.S. If I was the president of some Programming
> Entities Naming Committee

That will never happen.

> I would not endorse "jagged" term. I
> would try to find something better.

<snip>

Jagged is a fine term to apply to entities that exhibit jaggedness. It
is even an acceptable term to apply to entities that could exhibit
jaggedness but don't happen to in a specific instance. It is not an
appropriate term to apply to entities that are incapable of exhibiting
jaggedness, but as you are the only person who wants to do that (and are
incapable of providing any relevant justification for your decision) the
only folly here is yours, and you are the only person who need be
involved in correcting it.

Richard.


Richard Cornford

unread,
Feb 12, 2006, 9:10:01 AM2/12/06
to
VK wrote:
> Richard Cornford wrote:
>> VK wrote:
>>> Richard Cornford wrote:
<snip>
>>>> It makes no real difference. In your self-proclaimed role
>>>> as "the best specialist of *JavaScript arrays* on the
>>>> planet" you still wrote those lines, and needed to be
>>>> told by a lesser mortal that they were nonsense.
>>>
>>> Yes: *6 months ago*.
>>
>> So 6 months ago you were not the self-proclaimed "the best
>> specialist of *JavaScript arrays* on the planet"? And what
>> exactly has changed in the intervening period?
>
> A lot of study.

But you are the person for whom study results in your beliefs becoming
more false.

> Also please note that "the best specialist of *JavaScript
> arrays* on the planet" had been used in the polemic context

You still made that claim. Laughable as everyone else found it.

> of "the best JavaScript writers in the world in this group"
> which was said first and not by me.

An opinion about others from someone with the experience to apply
judgement to his opinions.

In your constant appeals to unnamed "professional programmers and
programming specialists" and un-cited "academic" sources you appear to
be assuming that all the contributors to this group are uninformed
amateurs dabbling in browser scripting as a hobby. While in reality the
bulk of the contributors to this group are active professional
programmers, some are browser scripting specialists and there are even
computer science academics. And you can easily see this in the veracity
of the statements they make here. Statements often made with the
openness of the individuals full name, rather than hiding behind the
anonymity of an arbitrary label.

You are certainly not a professional programmer (even if someone may be
fool enough to pay you to write computer code). That is evident, if from
no other source, in your total inability to comprehend or employ logic
(one of the mainstays of computer programming). You cannot see that in:-

| Neither C++ or Java array are *obligated* to be multi-dimensional.
| In any language I can perfectly create a simple single-dimention
| array. Applying your own thesis: "The very fact that you must
| have more than one dimension in order to implement the concept of
| `multi-dimensional' means that the term _cannot_ apply to a C++
| array (singular)."

- the conclusion cannot be derived from the perms, or that the only
conclusion that can be derived is unrelated to the conclusion you drew
and utterly trivial.

The only valid derivation is that single-dimension and multi-dimension
have a mutually exclusive relationship, which follows trivially from the
definitions of "single" and the prefix "muti", but as the C++ array can
have any number of dimensions, including one, the trivial exclusive
relationship between single-dimension and multi-dimensional doesn't
apply as a characteristic of the C++ array, only as characteristic of
individual C++ array instances.

>>> So it's nothing like "jagged because it contains links
>>> of different length" and other Of Kings And Cabbage stuff
>>> posted here over the last 48 hrs by different people.
>>
>> Is that intended to mean something?
>
> It means when when I answered OP's question using proper
> academically correct terms,

But those are only academically correct terms for something other than
the subject you applied them to. The supposedly academically originating
definitions you quoted said as much.

> I had to vaste my time and patience to answer on a
> bunch of mostly irrelevant posts of kind of "Prove
> that the Earth is rounded", "And now prove that the
> sky is blue" etc.

But the statement you are trying to defined is along the lines of 'air
molecules re blue, and you should be asked to defend that position if
you are going to take it.

> If something is not as you taught and thought of it to be,
> what VK has to do with it?

The something that is, is as it is independently of what either of us
may say on the subject, but what you are saying on the subject is
irrational and that has a great deal to do with you personally.

> Go unleash you frustration on the first available wiki
> (or two), not on me.

Why, you are the cause of the problem, only making you see that your
mental processes are error-producing could result in your correcting
your faulty behaviour.

>> Which suffers from your misguided filtering out of what
>> appears (or at the time appeared) to you not to be mistaken.
>
> This is why I checked myself over different reputable sources
> to make sure that my "mental filters" do not filter out
> something important.

But you don't see how this self-checking is letting you down? You post
statements that are absolutely and demonstrably false when applied to
javascript on a regular basis. You argue when your are validly
corrected, maintaining the truth of your statements, posting snippets of
code that don't actually do what you think they do, and you even go off
and bother bug reporting systems with examples of things that are not
doing what you think they should be doing but are actually completely
correct. And in general waste a great deal of time being repeatedly
corrected for errors that others would only need to see pointed out
once.

> Personal "mental filters" check is an important thing everyone
> needs to make on a not so frequent but regular basis.

When your 'mental filters' reject the proposition that your mental
filters are fundamentally erroneous you can check yourself as often as
you like and never see reason to change anything. The opinions of others
are very impotent in forming an objective assessment of your 'mental
filters', assuming that they can avoid automatically filtering those
opinions as well.

Richard.


VK

unread,
Feb 12, 2006, 10:39:42 AM2/12/06
to

Richard Cornford wrote:
> Jagged is a fine term to apply to entities that exhibit jaggedness. It
> is even an acceptable term to apply to entities that could exhibit
> jaggedness but don't happen to in a specific instance. It is not an
> appropriate term to apply to entities that are incapable of exhibiting
> jaggedness, but as you are the only person who wants to do that (and are
> incapable of providing any relevant justification for your decision) the
> only folly here is yours, and you are the only person who need be
> involved in correcting it.

Despite you're trying to point to my own vocabulary problems, you show
(or more probably pretending to show) even more serious vocabulary
problems.

I'm repeating it in Nth and the last time, as it's getting really
boring:

"jagged" in application to array doesn't mean "irregular on the
borders", "ragged" etc. These are meanings from the common vocabulary.

Jagged array means an array whose elements are arrays. The elements of
a jagged array *can be* of different dimensions and sizes. This is why
the term "jagged" has been originally coined. A jagged array is also
sometimes called an "array-of-arrays". Being an array-of-array and
being *able* (but not required to) to contain arrays of different
dimensions and sizes are the key features to take it away from a real
multidimensional array.

This is why I'm not happy with the term "jagged": it doesn't describe
well the nature of the entity which it names.

Still I tend to believe that the most basic knowledge of English (plus
some programming skills of course) suffice now to get the picture
right.

Here is an MSDN link
<http://msdn.microsoft.com/library/en-us/csref/html/vclrfjaggedarrays.asp>
- I took it not as the most reputable source, but as the most plain
language written among my collection.

So once again:

JavaScript / JScript array is:

Dynamic
- which doesn't imply this property usage. You can instantiate an
array of some size and stay within this size only.

Sparse
- which doesn't imply this property usage. You can go strictly by ++
/ -- index increment.

Jagged
- which doesn't imply this property usage. You can instantiate a
regular single-dimension array without any arrays as its elements.

Some sources also suggest to use "multi-typed" as indication of
possibility to have elements of different types in the array. I do not
stay for it as it seems formally incorrect to say "multi-typed" in a
type loose language.

Richard Cornford

unread,
Feb 12, 2006, 1:46:31 PM2/12/06
to
VK wrote:
> Richard Cornford wrote:
>> Jagged is a fine term to apply to entities that exhibit
>> jaggedness. It is even an acceptable term to apply to
>> entities that could exhibit jaggedness but don't happen
>> to in a specific instance. It is not an appropriate term
>> to apply to entities that are incapable of exhibiting
>> jaggedness, but as you are the only person who wants to
>> do that (and are incapable of providing any relevant
>> justification for your decision) the only folly here is
>> yours, and you are the only person who need be involved
>> in correcting it.
>
> Despite you're trying to point to my own vocabulary problems,
> you show (or more probably pretending to show) even more
> serious vocabulary problems.

Like what?

> I'm repeating it in Nth and the last time, as it's getting
> really boring:

Yes, you should stop repeating yourself and do something about
addressing the substantive criticisms of the potion you have taken.

> "jagged" in application to array doesn't mean "irregular on
> the borders", "ragged" etc. These are meanings from the common
> vocabulary.

If you didn't want the 'common vocabulary' applied to your statement why
did you quote the common definition?

> Jagged array means an array whose elements are arrays.

So a construct that must involve at least two javascript Arrays (if it
is to have any potential to exhibit jaggedness).

<snip>


> This is why I'm not happy with the term "jagged": it doesn't
> describe well the nature of the entity which it names.

No, it is a fine way of describing the entities that it names, the issue
here has been that you want to apply the label to an object that is not
one of the entities that it can be applied to.

> Still I tend to believe that the most basic knowledge of
> English

And in the absence of any apparent real understanding of English I
suppose you are only left with believing you have such an understanding.

> (plus some programming skills of course)

You can always specuatle.

> suffice now to get the picture right.

They should suffice, if you had either.

A page on C# that states that "A jagged array is an array whose elements
are arrays", and so once again describes a construct created with arrays
and not a characteristic of an array (in C# or javascript).

> - I took it not as the most reputable source, but as the
> most plain language written among my collection.

And again a statement that describes/categorises a structure and does
not even attempt to make a statement about the nature of an array object
in the pertinent language.

> So once again:
>
> JavaScript / JScript array is:
>
> Dynamic
> - which doesn't imply this property usage. You can instantiate
> an array of some size and stay within this size only.

Where dynamicsness is a fundamental characteristic of a javascript
Array. all arrays may be subject to runtime modification.

> Sparse
> - which doesn't imply this property usage. You can go strictly
> by ++ / -- index increment.

Where sparseness is a fundamental characteristic of a javascript Array.
all javascript arrays either are sparse or can be rendered sparse.

> Jagged
> - which doesn't imply this property usage.

That doesn't really mean anything.

> You can instantiate a regular single-dimension array

All javascript Arrays are single-dimensional, that is also a
characteristic of the javascript Array.

> without any arrays as its elements.

If a 'jagged array' is an array or arrays (or any other name for a
construct that requires more than one javascript Array) then all objects
that are not arrays of arrays (or constructs made with more than one
javascript Array) cannot be a 'jagged array'. And a javascript Array is
not an array of arrays. The qualities of the construct do not transfer
to its components by virtue of their potential to be used as such
components.

> Some sources also suggest to use "multi-typed" ...
<snip>

More irrelevant misdirection?

Richard.


VK

unread,
Feb 12, 2006, 3:37:19 PM2/12/06
to

Richard Cornford wrote:
> > (plus some programming skills of course)
>
> You can always specuatle.

That was not anything personal, just a side note for possible readers.

> > Dynamic
> > - which doesn't imply this property usage. You can instantiate
> > an array of some size and stay within this size only.
>
> Where dynamicsness is a fundamental characteristic of a javascript
> Array. all arrays may be subject to runtime modification.

*May* - but don't have to. But this attribute is used to define this
particular array model.

> > Sparse
> > - which doesn't imply this property usage. You can go strictly
> > by ++ / -- index increment.
>
> Where sparseness is a fundamental characteristic of a javascript Array.
> all javascript arrays either are sparse or can be rendered sparse.

*Can* - but don't have to. But this attribute is used to define this
particular array model.

var arr = new Array(1,2,3);
// Currently it's not a sparse array
// It's a condensed array (and please - it is not
// "another of VK's proprietary terms", OK?)
// the only personal term I ever used was "psi-link"
arr[1000] = 4;
// Now it's a sparse array


> > Jagged
> > - which doesn't imply this property usage.
>
> That doesn't really mean anything.

Don't cheat now ;-)

> > You can instantiate a regular single-dimension array
>
> All javascript Arrays are single-dimensional, that is also a
> characteristic of the javascript Array.

Jagged array is Array Of Arrays. Note the number of the first noun:
it's sungular. Array (one) Of Arrays - not Multidimensional array. Very
important attribute used in the model description.

var arr = [[2,3],[6,5],[0,9]];
This array has evenly sized "pseudo-dimensions" but it's still
*jagged*, not multidimensional. It's still really a sinle-dimension
array, you still can do things you can do only with jagged array like:

function byNumbers(a,b) {return a-b;}
arr.sort(byNumbers);

John G Harris

unread,
Feb 12, 2006, 4:35:03 PM2/12/06
to
In article <1139758782.4...@z14g2000cwz.googlegroups.com>, VK
<school...@yahoo.com> writes

<snip>


>Some sources also suggest to use "multi-typed" as indication of
>possibility to have elements of different types in the array. I do not
>stay for it as it seems formally incorrect to say "multi-typed" in a
>type loose language.

You are cheating when you say that. Javascript has clearly defined
types. If an Array object has some objects that are Array objects and
some that are not then you have the general case, which is where you
should be starting from. The classification of structures built from
Array objects and non-Array elements then goes as follows :

a) Tree.
General case.
Array objects provide the links to subtrees.

b) Some trees are also n-dimensional arrays.
Their leaf nodes are all at the same depth.

c) Some n-dimensional arrays are also regular. I.e not jagged.
Array objects at the same depth all have the same length.

d) Some regular n-dimensional arrays also have the same type at all the
leaf nodes. E.g All are Numbers.
This is a common case in javascript programs.

John

--
John Harris

Richard Cornford

unread,
Feb 12, 2006, 5:15:07 PM2/12/06
to
VK wrote:
> Richard Cornford wrote:
<snip>

>>> Dynamic
>>> - which doesn't imply this property usage. You can
>>> instantiate an array of some size and stay within
>>> this size only.
>>
>> Where dynamicsness is a fundamental characteristic of a
>> javascript Array. all arrays may be subject to runtime
>> modification.
>
> *May* - but don't have to. But this attribute is used to
> define this particular array model.

Dynamic is not "used to define this particular array model", it is a
characteristic of javascript Arrays in general.

>>> Sparse
>>> - which doesn't imply this property usage. You can go
>>> strictly by ++ / -- index increment.
>>
>> Where sparseness is a fundamental characteristic of a
>> javascript Array. all javascript arrays either are sparse
>> or can be rendered sparse.
>
> *Can* - but don't have to. But this attribute is used to
> define this particular array model.

Sparse is not "used to define this particular array model", it is a
characteristic of javascript Arrays in general; all javascript arrays
can be rendered sparse (as a consequence of having the potential to be
sparse combined with being dynamic).

> var arr = new Array(1,2,3);
> // Currently it's not a sparse array
> // It's a condensed array (and please - it is not
> // "another of VK's proprietary terms", OK?)
> // the only personal term I ever used was "psi-link"

You do, however, apply many terms inappropriately (or just employ them
in nonsensical contexts).

> arr[1000] = 4;
> // Now it's a sparse array
>
>
>> > Jagged
>> > - which doesn't imply this property usage.
>>
>> That doesn't really mean anything.
>
> Don't cheat now ;-)

I am not cheating. that is a statement that is insufficient to say
anything, and in saying nothing it also means nothing.

>>> You can instantiate a regular single-dimension array
>>
>> All javascript Arrays are single-dimensional, that is
>> also a characteristic of the javascript Array.
>
> Jagged array is Array Of Arrays.

And an array of arrays is a construct built with arrays.

> Note the number of the first noun:
> it's sungular. Array (one) Of Arrays - not Multidimensional
> array.

And the "Arrays" is plural, making the construct something that is not
an Array.

> Very important attribute used in the model description.
>
> var arr = [[2,3],[6,5],[0,9]];

A javascript Array initialiser that has three more javascript Array
initialisers defining the elements of the first array (total of 4
Arrays).

> This array has evenly sized "pseudo-dimensions" but it's
> still *jagged*, not multidimensional.

It has more than one dimension and you consider that as not being
multi-dimensional?

> It's still really a sinle-dimension array,

"It" is not "a single dimension array", "it" is a construct made with
four javascript Arrays. "It" is a construct to which the label 'jagged
array' can be applied as it satisfies the quoted definitions, but "it"
is not a javascript Array.

> you still can do things you can do only with jagged array
> like:

Fine, but "it" is _not_ a javascript Array so what it is, and whatever
can be done with it, does not transfer qualities on to javascript
Arrays.

> function byNumbers(a,b) {return a-b;}
> arr.sort(byNumbers);

Wouldn't it be an ides, just occasionally, to test code before you post
it?

Richard.


Thomas 'PointedEars' Lahn

unread,
Feb 12, 2006, 5:29:30 PM2/12/06
to
Richard Cornford wrote:

> VK wrote:
>> function byNumbers(a,b) {return a-b;}
>> arr.sort(byNumbers);
>
> Wouldn't it be an ides, just occasionally, to test code before you post
> it?

I do not understand what you mean by that. The posted source code certainly
sorts the array elements of the array encapsulated by `arr' according to the
numerical greater-than relation. `byNumbers' is one of the simplest and
most efficient comparators possible.


PointedEars

Richard Cornford

unread,
Feb 12, 2006, 6:30:54 PM2/12/06
to

No it doesn't. On IE 6 it produces a "Number Expected" error.

Arrays inherit their valueOf methods from Object.prototype, which
returns the - this - value of the object. The - this - value is not
primitive so the type-conversion to number process will call toString on
the arrays (see the definition of [[DefaultValue]]) and then convert
those values to a number, where the result will likely be Numeric NaN
(because of the commas in the string value of an array), which will
hardly enable meaningful sorting of the array.

The value returned from the comparison function is expected to be a
non-NaN number (Section 15.4.4.11) and so an error reading 'Number
Expected" when the result is Not a Number (NaN) is correct and
informative when the comparison function does return NaN.

Richard.


Thomas 'PointedEars' Lahn

unread,
Feb 12, 2006, 8:33:39 PM2/12/06
to
Richard Cornford wrote:

> Thomas 'PointedEars' Lahn wrote:
>> Richard Cornford wrote:
>>> VK wrote:
>>>> function byNumbers(a,b) {return a-b;}
>>>> arr.sort(byNumbers);
>>> Wouldn't it be an ides, just occasionally, to test code
>>> before you post it?
>> I do not understand what you mean by that. The posted source
>> code certainly sorts the array elements of the array encapsulated
>> by `arr' according to the numerical greater-than relation.
>> `byNumbers' is one of the simplest and most efficient comparators
>> possible.
>
> No it doesn't.

Yes, it does. But not for /this/ Array object :)

> On IE 6 it produces a "Number Expected" error. [...]

I now see you are referring to the initialized value of `arr' explicitly:

| var arr = [[2,3],[6,5],[0,9]];

Yes, of course, with /that/ value (i.e. a "two-dimensional array"; sorry, I
know no better concise expression, maybe you can enlighten me) the sorting
does not work as supposed in Gecko-based UAs and Opera 8.51/Linux as well;
however, there is no error (and no warning).

Interestingly, Gecko-based UAs return the expected "2,3,6,5,0,9" while Opera
returns "0,9,6,5,2,3" as string representation of the Array object [without
modifying Array.prototype.toString() before.]


PointedEars

VK

unread,
Feb 13, 2006, 2:30:10 AM2/13/06
to
var arr = [[2,3],[6,5],[0,9]];

function byNumbers(a,b) {return a[1]-b[1];}

arr2 = arr.sort(byNumber);

By context (if you understand what jagged array is and how does it
differ from a multidimensional one) one could see the typo.

No need to post so many useless words instead.

Richard Cornford

unread,
Feb 13, 2006, 2:54:34 AM2/13/06
to
Thomas 'PointedEars' Lahn wrote:
> Richard Cornford wrote:
>> Thomas 'PointedEars' Lahn wrote:
>>> Richard Cornford wrote:
>>>> VK wrote:
>>>>> function byNumbers(a,b) {return a-b;}
>>>>> arr.sort(byNumbers);
^^^

>>>> Wouldn't it be an ides, just occasionally, to test code
>>>> before you post it?
>>> I do not understand what you mean by that. The posted source
>>> code certainly sorts the array elements of the array encapsulated
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

>>> by `arr' according to the numerical greater-than relation.
^^^^^^^^
<snip>

>>
>> No it doesn't.
>
> Yes, it does. But not for /this/ Array object :)

But it was this array that the posted code was trying to sort. And I had
assumed that when you said "sorts the array elements of the array
encapsulated by `arr'" that you were referring to the same array.

>> On IE 6 it produces a "Number Expected" error. [...]
>
> I now see you are referring to the initialized value of `arr'
> explicitly:

Yes, I am hardly likely to maintain that arrays cannot be sorted, or
even that the array in question cannot be sorted, just that the code VK
posted and stated would work does not do anything useful when it doesn't
error and does error-out on the most common web browser in use.

>| var arr = [[2,3],[6,5],[0,9]];
>
> Yes, of course, with /that/ value (i.e. a "two-dimensional array";
> sorry, I know no better concise expression, maybe you can enlighten
> me)

I don't have any problem with labelling that construct as a
two-dimensional array.

> the sorting does not work as supposed in Gecko-based UAs and
> Opera 8.51/Linux as well;

The specification doesn't say how it is supposed to work when the
comparison function does not meet the requirements of the specification
(to return a non-NaN number).

> however, there is no error (and no warning).

The interpreter's response to the flawed comparison function is not
specified so any behaviour, from erroring to silence, is acceptable.

> Interestingly, Gecko-based UAs return the expected "2,3,6,5,0,9"
> while Opera returns "0,9,6,5,2,3" as string representation of the
> Array object [without modifying Array.prototype.toString() before.]

As the actual sorting algorithm is not specified it would be possible
for every implementation to use a different algorithm, with a different
outcome when the values returned from the comparison function are
essentially meaningless.

Richard.


Richard Cornford

unread,
Feb 13, 2006, 3:01:52 AM2/13/06
to

That is completely irrelevant to the message you have responded to
(Which was Message-ID: dsnfjr$p4a$1$830f...@news.demon.co.uk).

But if you are embraced by posting code that does not work you can avoid
the condition by doing no more than testing it before you post it. It
would help if you started with the realisation that you are not at all
good at javascript and cannot trust the untested products of you mind to
be correct.

Richard.


VK

unread,
Feb 13, 2006, 3:06:07 AM2/13/06
to

Richard Cornford wrote:
> Yes, I am hardly likely to maintain that arrays cannot be sorted, or
> even that the array in question cannot be sorted, just that the code VK
> posted and stated would work does not do anything useful when it doesn't
> error and does error-out on the most common web browser in use.

God damn it was an after-midnight typo, sorry again.

var arr = [[3,2],[4,3],[6.7]];

function by2nd(a,b) {
return a-b;
}

var arr2 = arr.sort(by2nd);

P.S. Yes it requires extra code for string values
P.P.S. Yes it requires extra code for mixed values

I hope though that the intended idea is expressed clearly now.

If you still need more explanations what "jagged" and
"multidimensional" arrays are and why they are not the same, I will try
to help.

Richard Cornford

unread,
Feb 13, 2006, 3:48:11 AM2/13/06
to
VK wrote:
> Richard Cornford wrote:
>> Yes, I am hardly likely to maintain that arrays cannot be sorted, or
>> even that the array in question cannot be sorted, just that the code
>> VK posted and stated would work does not do anything useful when it
>> doesn't error and does error-out on the most common web browser in
>> use.
>
> God damn it was an after-midnight typo, sorry again.

It was not a typo, it was technically uninformed code posted in the
arrogant and misguided belief that what comes out of your mind has some
relationship to javascript. Typos are minor mistakes in code that would
work otherwise not the use of completely inappropriate expressions.

> var arr = [[3,2],[4,3],[6.7]];
>
> function by2nd(a,b) {
> return a-b;
> }
>
> var arr2 = arr.sort(by2nd);
>
> P.S. Yes it requires extra code for string values

And did you test that code? "Number Expected" again, you just don't take
good advice do you? Didn't I mention that everyone makes mistakes but it
takes a real fool to repeat them?

> P.P.S. Yes it requires extra code for mixed values

I don't think so, it will error-out just as quickly with any value type
in the inner arrays.

> I hope though that the intended idea is expressed clearly now.

That doesn't matter as what you have clearly expressed is probably more
informative in context.

> If you still need more explanations what "jagged" and
> "multidimensional" arrays are and why they are not the same,

Not why they are not the same but why you think one is applicable to an
array of arrays and the other is not.

> I will try to help.

You could help by actually answering the original question and explain
how a quality of a specific type of construct can reasonably be
transferred to the components of that structure, even though those
components are logically incapable of exhibiting that quality at all.

Beyond that there is little help you could offer anyone as your
understanding of javascript is superficial and error-filled and you are
irrational.

Richard.


Richard Cornford

unread,
Feb 13, 2006, 3:52:30 AM2/13/06
to
Richard Cornford wrote:
<snip>
> But if you are embraced by posting code ...

That should be 'embarrassed', and was an example of a typo :)

Richard.

Randy Webb

unread,
Feb 15, 2006, 2:22:19 AM2/15/06
to
Richard Cornford said the following on 2/13/2006 2:54 AM:
> Thomas 'PointedEars' Lahn wrote:

<snip>

>> Yes, of course, with /that/ value (i.e. a "two-dimensional array";
>> sorry, I know no better concise expression, maybe you can enlighten
>> me)

"Array of Arrays"

> I don't have any problem with labelling that construct as a
> two-dimensional array.

You should as JS doesn't have a two-dimensional array :)

two-dimensional leads to multi-dimensional, neither of which JS possesses.

It's an array of arrays.


--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

It is loading more messages.
0 new messages