I am looking to incorporate both limit and fill within the same array.
var array = new Array(4).fill({});
var limit = 4;
If there are dynamic records, the number may vary but I only need 4 records to display. For example: eg-1 records = 20 It should display only the first 8 records in the array. Output:
[{record 1},{record 2},{record 3},{record 4}]
Eg-2: Records = 2; It should display those 2 records and the remaining 6 indices should be filled with {} Output:
[{record 1},{record 2},{},{}]
So how can I accomplish this?