Copyright 2025

The Valley of Code

A Flavio Copes project

How to initialize a new array with values in JavaScript
Find out how you can initialize a new array with a set of values in JavaScript

Simple solution:

Array(12).fill(0)

fill() is a new method introduced in ES6.


Want to master TypeScript? Check out my TypeScript Masterclass

Join my AI Workshop !

The Web Development BOOTCAMP cohort starts in February 2026