I have an array of objects in array notation. This array is going to be different every time.
I wish to be able to get the name of the elements in this array. The trouble I am having is that [object] is returned instead of returning assetA, for example. I know this is because assetA is an object itself.
An example of the code I have been using to test this is..
//the assetArray will have varying number of elements in the future
var assetArray=[assetX,assetY,assetZ, assetB, assetA];
var testtest=(new String(assetArray));
alert(testtest);
$.each(assetArray,function(intIndex,objValue){
var test123=(new String(assetArray[intIndex]));
alert(test123);
});
and the list of test assets are..
var assetX = {
assetNumber: "TESTX",
assetDescription: "FLUX CAPACITOR",
assetManufacturer: "Honeywell",
assetCustomer: "MCFLY",
assetDate: "03/04/1956"
};
var assetY = {
assetNumber: "C123Y",
assetDescription: "HOVERBOARD",
assetManufacturer: "GE",
assetCustomer: "MCFLY",
assetDate: "12/03/1945"
};
var assetZ = {
assetNumber: "9000Z",
assetDescription: "ROCKETFOOTBALL",
assetManufacturer: "Fluke",
assetCustomer: "MCFLY JR.",
assetDate: "01/05/3030"
};
var assetA = {
assetNumber: "C34JJXA",
assetDescription: "TEST DESCRIPTION",
assetManufacturer: "Elgar",
assetCustomer: "CUSTOMER1",
assetDate: "05/09/1923"
};
var assetB = {
assetNumber: "C892ALB",
assetDescription: "DMM",
assetManufacturer: "Agilent",
assetCustomer: "CUSTOMER2",
assetDate: "02/12/1986"
};
Does anyone have experience with this kind of issue using jQuery?
Store your asset objects in an object as properties (i.e. use an associative array instead of an ordinal array):