I am attempting to set up a short hand in JavaScript and Vue.js for an Array Object with a length of 5, then destructure the values of the array Object into a new array. In my Vue.js project, I added the following "finalArray" property, along with the .keys() property to reassign the object keys as the values passed into each new array object:
const finalArray = ref([...Array(5).keys()])
Instead of returning an array object with the keys assigned as the values, I wish to return an array of objects with each object value represented as an empty string, like so:
[
{0: ""},
{1: ""},
{2: ""},
{3: ""},
{4: ""},
]
However, when I remove the keys() property, I get undefined
as the value on the key-value pair of each object. How can I set up the Array object (with a length of 5) to return each object with the values represented as empty strings?