Let\'s say I have an array with data elements, in this example numbers, like this:
var a = [432, 238, 122, 883, 983];
And I want to limit t
Just to add another possible alternative:
a = [x, ...a.slice(0, 6)];
Even though I would personally choose Nina Scholz's solution (with a "better" condition for changing length and for older environments where ES6 is not supported)
References: