Home >Operation and Maintenance >Safety >How Javascript fills an array with data
If we need to fill the array with some data, or need a data with the same value, we can use the fill() method.
var plants = new Array(8).fill('8'); console.log(plants); // ['8', '8', '8','8', '8', '8','8', '8']
The above is the detailed content of How Javascript fills an array with data. For more information, please follow other related articles on the PHP Chinese website!