following is an array that needed to be store on local storage when the dom is created.
this.headers.push(
{
text: "Name",
align: "center",
sortable: true,
value: "name",
align: "start",
},
{
text: "Company",
align: "center",
sortable: true,
value: "company",
align: "start",
},
{
text: "Phone",
align: "center",
sortable: true,
value: "phone",
align: "start",
},
)]
the value of each object needed to be store on localstorage under the key name el_columns
. so I have tried as follows.
this.headersList.forEach((element) => {
localStorage.setItem(
"el_columns",
JSON.stringify(element.value)
);
});
the above code works fine but is stores only one value which is the last object value phone
. the output i expect is like follows ['name', 'company', 'phone']