fill an array with same number n times js code example Example: javascript repeat element in array Array(5).fill(2) //=> [2, 2, 2, 2, 2]