In C#, I can create a class that acts as a user-defined type, such as:
Public Class FullName
{
string FirstName;
string LastName;
}
Public Class Address
{
string Line1;
string Line2;
string City;
string State;
string Zip;
}
and then I can create:
Public Class Person
{
FullName Name;
Address HomeAddress;
Address WorkAddress;
}
This allows me to reference the data like:
Person Bob;
Bob.WorkAddress.Line1 = "123 Sycamore Rd";
Bob.HomeAddress.Line1 = "1313 MockingBird Ln";
Bob.FullName.LastName = "Smith";
etc...
Ultimately, I want to create a 2D array of Person, so I don't want to hardcode (pre-populate?) the data until I know what it is.
I'd like to be able to do the same thing in JavaScript (specifically node.js), but can't seem to find an obvious way of doing so. Is this just fundamentally the wrong approach, or am I just missing something?
via Chris G. Williams
No comments:
Post a Comment