Whenever a button is clicked on the page, I am dynamically creating an array in javascript using item id's fetched from the database. Each entry in the array will hold a custom object.
The id's retrieved from the database can range from numbers like 80123 to 80223 for a specific set of data displayed on the page.
For example, the first element in the array would be represented as arr[80123].
However, despite having only one element in the array, when I check its length it displays 80123! I considered using associative or character indexed arrays but they do not provide the necessary sorting operations required.
My current query is: "With just one element in the array and a length of 80123, how much memory will it actually consume?"
Additional details:
The starting number (e.g., 80123) can vary based on the data being processed.
Below is the snippet of code being implemented:
function ToggleAction(actionButtonID, action)
{
var extractedID = ExtractNumericIdFromTag(actionButtonID);
var arrayIndexer = extractedID; // This can be modified for associativity
if(actionItems[arrayIndexer] == null)
{
actionItems[arrayIndexer]
= new ActionItem(extractedID, action);
}
else
{
var ai = actionItems[arrayIndexer];
ai.action = action;
}
}