The idea is to remove duplicate id's upon selection of records using checkbox. Below is the code used.
selectedTaskObj3 = [];
let el = this.template.querySelector("lightning-datatable");
let selectedRowsArray = el.getSelectedRows();
//**note**: until here I get the output as an object array
let selectedTaskObjChecktest = JSON.stringify(selectedRowsArray).map((item)=>item.Id)
this.selectedTaskObj3 = Array.from(new Set(selectedTaskObjChecktest));
However it is working perfect in console log but not on the page which is totally strange.
JSON.stringify
the data, thus making a "string", so the map function would fail.JSON.stringify
in the console. You have yourobjArray
object, which you then callmap
on. What happens in your code above when you callselectedRowsArray.map
?