I am trying to do something very basic in TypeScript. Get a list of unique strings when parsing the map, as indicated in this post.
Here is what I am trying to do:
let myData = new Array<string>();
for (let myObj of this.getAllData()) {
let name = myObj.name;
console.log("## we have " + name);
console.log("### is property ? " + myData.hasOwnProperty(name));
if (!myData.hasOwnProperty(name)){
myData.push(name);
}
}
My listing will always evaluate to false for any row, duplicate or not. Here are some examples:
#
#
#
#
#
#
#
#
However, when the process ends, my list contains duplicates. I tried looking at this documentation , but not hashset or any set at all.
Is there something equivalent in TypeScript typing? ie List of unique items
source
share