I have an object array created and it's like this:
for(var i =0; i < this.test.length; i ++){
var header = this.test[i].hdr;
var insertData = [];
switch(header){
case 'date':
insertData = {date: "date"};
break;
case 'name':
insertData = {name: "name"};
break;
case 'age':
insertData = {age: "age"};
break;
case 'add':
insertData = {add: "add"};
break;
}
this.hdrtxt.push(insertData);
}
Now, when I try to get the keys of the object, I used this:
Object.keys(this.hdrtxt);
The result is:
(4) ["0", "1", "2", "3"]
But the output I want is this:
(4) ["date", "name", "age", "add"]
I'm sorry I'm just new to this. How can I attain my goal?
Object.keys(this.hdr)?.hdrlooks like a property of each object in thethis.testarray.