InterviewHubPRO
Section Overview
Q374

Question 374 of 521

Part 6: Async Internals, Memory, Microtasks & Web APIs (329 - 403)

72%
JavaScript Internals (521 Qs)•Part 6: Async Internals, Memory, Microtasks & Web APIs (329 - 403)

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.

javascript
  var newArray = new Array(5).fill("0");
  console.log(newArray); // ["0", "0", "0", "0", "0"]