Search code examples
stackblitzcodesandbox

Why I get this error (new Set(...)).slice is not a function?


I tried to run this code in any of the online code editors but I always get error

(new Set(...)).slice is not a function

Code:

myarray = ['d','s', 'a'];
chr_arr = [...new Set(myarray)];

why I get this error ?


Solution

  • This only valid on ECMA Script 6

    You need configure in tsconfig.json but online code editor (stackbliz) can't edit

    https://angular.io/guide/typescript-configuration