I am trying to populate items of an array with same items and order.
As an example, I have an array like this, with two string elements.
const myArr = ['A','B'];
What I'm trying to do is something like that. I need to populate items 10 times or more. I'm thinking of a for loop but maybe there are more efficient alternatives.
const myArr2 = ['A','B','A','B','A','B','A','B','A','B'];
How can I achieve this with Vanilla JS ?
TypedArray.prototype.setfor normal arrays. Therefore, something likeArray.from({ length: 10 }, () => ['A', 'B']).flat()is the best i can think of, or similar ways, that result in useless intermediary arrays, and pray the function inliner works properly