Recommended Approach
I would recommend modifying the objects in the array to include an ID
attribute. With this attribute in place you can use the filter
method on the array to find elements by their ID
property.
var ProductList = [
{ID: "11", Name: "Item name", Price: "0.99"},
{ID: "22", Name: "Item name", Price: "0.99"},
{ID: "33", Name: "Item name", Price: "8.99"},
{ID: "44", Name: "Item name", Price: "8.99"}
];
function findById(arr, id){
var results = arr.filter(function(e){
return e.ID == id;
});
return (results.length) ? results[0]:undefined;
}
Orignal Array
If you must stick with the original array the following can be applied.
You must access the object using the property name associated with each object in the array:
console.log(ProductList[1]["2"].Name);
If you can't change the structure of these objects I would make a helper function:
var ProductList = [
{"1": {Name: "Item name", Price: "0.99"}},
{"2": {Name: "Item name", Price: "0.19"}},
{"3": {Name: "Item name", Price: "8.99"}},
{"4": {Name: "Item name", Price: "8.99"}}
];
function getInternal(arr, index){
return arr[index][index+1];
}
var obj = getInternal(ProductList, 1);
console.log(obj.Name);
JS Fiddle: http://jsfiddle.net/68WDZ/