FrontendDeveloper.in

JavaScript question detail

How do you create an array with some data

You can create an array with some data or an array with the same values using fill method.

var newArray = new Array(5).fill("0");
console.log(newArray); // ["0", "0", "0", "0", "0"]
Back to all JavaScript questions
Get LinkedIn Premium at Rs 399