Create arrays and initiate data in a single statement.

Traditionally you would do the below to initiate the array and fill it with values -

let planets = ["mercury", "venus", "earth"];

This is a-ok if you know the values, but what if you want array to have fixed elements with pre-defaulted values? This is where fill (an ES6 feature) steps in.

let planets = new Array(3).fill("");
console.log("planets: ", planets); // [ '', '', '' ]

You could also instantiate only certain elements of the array as well.

let allMyNums = new Array(5).fill(0, 1, 5);
console.log("allMyNums: ", allMyNums); // <1 empty item>, 0, 0, 0, 0

fill is both fast and efficient. But it can support instantiating with a single value.

We do not have a comparable feature for objects - it may not make a lot of sense to create ten empty properties :)