I have an array that is constructed like:
Currently, all the solutions I've tried are similar, such as:
this.quantities = this.quantities.filter(e => e.length);
These however goes ahead and deletes out all the empty arrays (as desired) and re-keys the array down, as is normal behaviour (ant not desired), so 500, 1000, 5000 becomes 1, 2 & 3.
Is there a way to cull the empty arrays without re-keying? Because I am feeling the memory issues, especially as we get into a higher range.
Here's a snippet of the front-end view for the project:
I understand that I can just refactor my code to use a reference object - but as is the nature with business - I don't have a lot of time to spare refactoring and lookups by these quantity keys are woven throughout the project.
I am using VueJS & this is my method:
this.quantities[ this.enter_qty ] = [];
this.quantities[ this.enter_qty ][ 0 ] = {
quantity: this.enter_qty,
item_description: null,
supplier_contact_id: null
};
//this.quantities = this.quantities.filter(e => e.length);