I'm feeling a bit confused and would appreciate some explanations please!
In my code, I have a datatable that generates an array of Operation objects in my .ts file. Here is the object class:
export class Operation {
id: number;
name: string;
}
This is how the array is declared:
selectedOperations: Operation[];
When I log the selected operations in the console before extracting ids, I see this:
this.selectedOperations = {"selected":[{"id":1,"name":"My name 1"},{"id":3,"name":"My name 3"}]}
But when I try to extract ids using this code snippet:
let ids = this.selectedOperations.map(o => o.id);
I encounter an exception:
this.selectedOperations.map is not a function
I've faced similar issues before and I'm trying to understand why. Could it be related to differences between Array and object[]? The presence of {"selected": before the array makes me doubt if it's truly an array...
If anyone could shed some light on this issue and help me extract the ids, I would greatly appreciate it!
Thank you so much!