Get Array Name

S

Sunny

Hi,

Do anyone, Knows, How to get array Name?

Like If I have a array:
abc & I would like to get the name abc, How can I do that.
I am trying to set abc.name but its not working.

I have to get the array name, so that I can change them dynamically.
What to do?
 
S

Stevo

Sunny said:
Hi,

Do anyone, Knows, How to get array Name?

Like If I have a array:
abc & I would like to get the name abc, How can I do that.
I am trying to set abc.name but its not working.

You should show the code you're using which isn't working.

Assuming the code you have that wants to "do stuff" with an array takes
that array as a parameter, then why not make the caller pass in the
array name as a string. Example:

var myarray=[];
function doStuffTo(somearrayname)
{
window[somearrayname][0]="cool array[0] string";
}

doStuffTo("myarray");
I have to get the array name, so that I can change them dynamically.
What to do?

Can you explain more about what you mean by changing "them" dynamically.
 
E

Erwin Moller

Sunny schreef:
Hi,

Do anyone, Knows, How to get array Name?

Like If I have a array:
abc & I would like to get the name abc, How can I do that.
I am trying to set abc.name but its not working.

I have to get the array name, so that I can change them dynamically.
What to do?

Hi,

What do you mean excactly?

var myArr = [1,2,3];
var meToo = meArr;
hereIsAnArr(myArr);

function hereIsMyArr(someArr){
// do you want to find the name of the arr here?
// Then what name? myArr or meToo?
}

The 'name' of an array is just a variablename available in a certain
scope that POINTS TO (=reference) an array.
(I hope I phrased that right.)

Maybe I misunderstand what you mean. If so, please clarify.

Regards,
Erwin Moller


--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
 
E

Erwin Moller

Sunny schreef:
Hi,

Do anyone, Knows, How to get array Name?

Like If I have a array:
abc & I would like to get the name abc, How can I do that.
I am trying to set abc.name but its not working.

I have to get the array name, so that I can change them dynamically.
What to do?


Hi,

What do you mean excactly?

var myArr = [1,2,3];
var meToo = myArr;
hereIsAnArr(myArr);

function hereIsMyArr(someArr){
// do you want to find the name of the arr here?
// Then what name? myArr or meToo?
}

The 'name' of an array is just a variablename available in a certain
scope that POINTS TO (=reference) an array.
(I hope I phrased that right.)

Maybe I misunderstand what you mean. If so, please clarify.

Regards,
Erwin Moller


--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
 
E

Erwin Moller

Sunny schreef:
Hi,

Do anyone, Knows, How to get array Name?

Like If I have a array:
abc & I would like to get the name abc, How can I do that.
I am trying to set abc.name but its not working.

I have to get the array name, so that I can change them dynamically.
What to do?

[I posted a wrong version first, I hope the cancelation worked. :p]

Hi,

What do you mean excactly?

var myArr = [1,2,3];
var meToo = myArr;
hereIsAnArr(myArr);

function hereIsAnArr(someArr){
// do you want to find the name of the arr here?
// Then what name? myArr or meToo?
}

The 'name' of an array is just a variablename available in a certain
scope that POINTS TO (=reference) an array.
(I hope I phrased that right.)

Maybe I misunderstand what you mean. If so, please clarify.

Regards,
Erwin Moller




--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
 

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,138
Messages
2,570,802
Members
47,348
Latest member
nethues

Latest Threads

Top