Looking for a way to create object Array that has a fixed size of 3 that fills it with default values but when i come to push into the array it should replace the default values.
Example:
Declare an array which fills the array with a string of "default value"
["default value", "default value", "default value"]
I now push some text to this initial array and expect the following:
["Added Data", "Default value", "Default Value"]
I push more data to this array and expect the following:
["Added Data", "Added Data", "Default Value"]
Again I push more data to this array and expect the following:
["Added Data", "Added Data", "Added Data"]
So the end result should be if push one data then the remainder of array should remain the default value unless i push all three data into the array.
Note: This example is a string array just to show an example but the solution i am looking for is array of objects. The Array.fill() method works great for JavaScript immutable values like strings, numbers, and booleans. Array with objects, each slot in the array refers to the same object which is not what i am looking for. I want each object to be unique