What is the equivalent of Python set(string) in TypeScript

1 Answer

0 votes
function makeset(str: string) {
    const arr: string[] = [...str];
   
    const st: any = new Set(arr);
      
    return st;
}
  
const str: string = "TypeScript Programming";
   
console.log(makeset(str));
   
   
   
/*
run:
   
Set (16) {"T", "y", "p", "e", "S", "c", "r", "i", "t", " ", "P", "o", "g", "a", "m", "n"} 
   
*/

 



answered Feb 8, 2024 by avibootz
edited Feb 8, 2024 by avibootz

Related questions

2 answers 195 views
1 answer 101 views
1 answer 147 views
1 answer 197 views
1 answer 161 views
1 answer 148 views
1 answer 149 views
...