Array in javascript

R

Randy Webb

VK said the following on 2/3/2006 1:14 PM:
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.
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.
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.
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated Fri, 3 Feb
2006 09:48:55 remote, seen in Jasen Betts
No it is not because all arrays have a length property which tells you how
many elements they have :)

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".
 
V

VK

Randy said:
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.
 
V

VK

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.
 
R

Randy Webb

VK said the following on 2/4/2006 3:18 PM:
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.
 
D

Dr John Stockton

JRS: In article <[email protected]>
, dated Sat, 4 Feb 2006 14:34:09 remote, seen in
news:comp.lang.javascript said:
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.
 
D

Dr John Stockton

JRS: In article <[email protected]>,
dated Sat, 4 Feb 2006 12:18:11 remote, seen in
news:comp.lang.javascript said:
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.
 
R

Richard Cornford

VK said:
Randy Webb wrote:

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.
 
R

Richard Cornford

VK said:
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.
 
V

VK

Dr said:
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
 
R

Randy Webb

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.
 
V

VK

Randy said:
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.
 
T

Thomas 'PointedEars' Lahn

VK said:
Randy said:
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.
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
 
V

VK

Thomas said:
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? ;-))
 
R

Richard Cornford

VK said:
Randy Webb wrote:

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.
 
J

Jambalaya

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+"jagged+array"> so I
fear more people may be exposed to your "abstract model thinking."
 
V

VK

Jambalaya said:
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+"jagged+array"> 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.
 
R

Randy Webb

VK said the following on 2/7/2006 3:02 AM:

Wrong VK, even by your very own definition.
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?
 
V

VK

Randy said:
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).
 
R

RobG

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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top