Namespace Array

M

MC

I want to create an array that would be namespaced. What is the proper way
to do that? (Using the following two examples)

--Normal namespace object
MYNS.CarTypeCd = function() {}

--Normal Array
var CarTypeCd = new Array();
CarTypeCd [0] = new Array("Ford", "Pinto");
CarTypeCd [1] = new Array("GM", "Suburban");

doing
MYNS.CarTypeCd = new Array();
gets a CarTypeCd is not defined error.

Thank you,
Mica
 
M

MC

Stefan Weiss said:
I want to create an array that would be namespaced. What is the proper
way
to do that? (Using the following two examples)

--Normal namespace object
MYNS.CarTypeCd = function() {}

Did you mean

MYNS.CarTypeCd = {};

?
--Normal Array
var CarTypeCd = new Array();
CarTypeCd [0] = new Array("Ford", "Pinto");
CarTypeCd [1] = new Array("GM", "Suburban");

doing
MYNS.CarTypeCd = new Array();
gets a CarTypeCd is not defined error.

No, it doesn't?

How about this:

var MYNS = {
CarTypeId: []
};
MYNS.CarTypeId[0] = ["Ford", "Pinto"];
MYNS.CarTypeId[1] = ["GM", "Suburban"];

or even simpler:

var MYNS = {
CarTypeId: [ ["Ford", "Pinto"], ["GM", "Suburban"] ]
};

Stefan,
Thank you, that seems to work fine. I googled and looked in several books
and did not see an example of this.
Mica
 

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,770
Messages
2,569,586
Members
45,090
Latest member
ActivlifeKetoDiet

Latest Threads

Top