redimension 2-d array

D

drew

this appears to work:
//Step 1 - I globally defined K
var K = new Array(150);
for (var i = 0; i < 150; i++) { K = new Array(150);}


//Step 2 I call this function without the var before K
function function1()
{
K[149][149]=7;
K = new Array(1000);
for (var i = 0; i < 1000; i++) { K = new Array(1000);}
}

//Step 3 - I called function2 - all seems to work
function function2()
{
K[200][200]=7;
var text1 =K[200][200];//undefined - which is fine - hoping it garbage collected
var text2 =K[200][200];//7 - It seemed to work!
}

Will I run into trouble with this?
thank you
 
L

Lasse Reichstein Nielsen

drew said:
this appears to work: ....
K[200][200]=7;
var text1 =K[200][200];//undefined - which is fine - hoping it garbage collected

What is undefined? text1 should be 7. Should this line be before the
previous line?
var text2 =K[200][200];//7 - It seemed to work!
}

It's not clear whether you think you have a problem or not, and if so,
what it is.
Your code works as expected. If I guess your intentions correctly, it's
also what you want it to do, but it's impossible to be sure.
Will I run into trouble with this?

Probably not. What do you expect it to do?

/L
 

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
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top