G
Gene Wirchenko
Dear JavaScripters:
Were I to do
alert("junk="+junk);
and junk had not been declared, it would be an error. If junk had
been declared, the value would be displayed. This might be undefined.
With an array, the element need not have been assigned to to get
this behaviour. Declaring the array means that
alert("element="+theArray);
for some i will not throw an error on the element being undefined.
If I create a sparse array element, it is quick, as in:
theArray=new Array();
theArray[999999999]="way out there";
With the above figured out -- if I am at all wrong in the above,
please tell me -- I thought that I would check performance on large,
filled-in arrays.
The following code gives interesting results on my system. I
have played around with initial values for Expand and how much it is
incremented at the end of the loop.
When I try to get it to do the looping for expansion to
130,000,000, I get the confirmation box which I OK, I get the alert
box that it is starting, and THEN after a delay, I get the "Done"
text. I do not get the alert box that the looping is complete nor the
one that outputs fLooping. There is no error from my browser either.
Why is what is happening happening?
***** Start of Code *****
<html>
<head>
<title>try5.html</title>
<script type="text/javascript">
</script>
</head>
<body>
<script type="text/javascript">
theArray=new Array();
var OldMax=0;
var Expand=129000000;
var fLooping=true;
while (fLooping)
{
fLooping=confirm("Confirm do Expand="+Expand);
if (fLooping)
{
alert("doing Expand="+Expand);
for (var i=OldMax; i<Expand; i++)
theArray=i;
alert("done Expand="+Expand);
OldMax=Expand;
Expand+=100000;
}
}
alert("fLooping="+fLooping);
</script>
Done
</body>
</html>
***** End of Code *****
Sincerely,
Gene Wirchenko
Were I to do
alert("junk="+junk);
and junk had not been declared, it would be an error. If junk had
been declared, the value would be displayed. This might be undefined.
With an array, the element need not have been assigned to to get
this behaviour. Declaring the array means that
alert("element="+theArray);
for some i will not throw an error on the element being undefined.
If I create a sparse array element, it is quick, as in:
theArray=new Array();
theArray[999999999]="way out there";
With the above figured out -- if I am at all wrong in the above,
please tell me -- I thought that I would check performance on large,
filled-in arrays.
The following code gives interesting results on my system. I
have played around with initial values for Expand and how much it is
incremented at the end of the loop.
When I try to get it to do the looping for expansion to
130,000,000, I get the confirmation box which I OK, I get the alert
box that it is starting, and THEN after a delay, I get the "Done"
text. I do not get the alert box that the looping is complete nor the
one that outputs fLooping. There is no error from my browser either.
Why is what is happening happening?
***** Start of Code *****
<html>
<head>
<title>try5.html</title>
<script type="text/javascript">
</script>
</head>
<body>
<script type="text/javascript">
theArray=new Array();
var OldMax=0;
var Expand=129000000;
var fLooping=true;
while (fLooping)
{
fLooping=confirm("Confirm do Expand="+Expand);
if (fLooping)
{
alert("doing Expand="+Expand);
for (var i=OldMax; i<Expand; i++)
theArray=i;
alert("done Expand="+Expand);
OldMax=Expand;
Expand+=100000;
}
}
alert("fLooping="+fLooping);
</script>
Done
</body>
</html>
***** End of Code *****
Sincerely,
Gene Wirchenko