By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,741 Members | 1,973 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,741 IT Pros & Developers. It's quick & easy.

Get Array Name

P: n/a
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?
Oct 17 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On 2008-10-17 18:38, Sunny wrote:
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 are you talking about? Arrays don't have names.

(...that is, unless you assign them a .name property yourself, which
does in fact "work")

If you're asking how to find out the name of a variable that holds a
reference to an array, you're probably doing something else wrong. If
that's not what you were asking, maybe you should give a little more
sample code than "abc".
- Conrad
Oct 17 '08 #2

P: n/a
Sunny wrote:
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.
Oct 17 '08 #3

P: n/a
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
Oct 17 '08 #4

P: n/a
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
Oct 17 '08 #5

P: n/a
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
Oct 17 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.