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


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

why I get this error in stackblitz.com and codesandbox.io ?

I got it working using

Hi @william1, that code works for me if I just copy / paste it to the browser console; however
you forgot to declare both variables AFAICT. This will throw an error in strict mode; and since both stackblitz and codesandbox are module-based, and modules are in strict mode by default, that code won’t work in either without proper declarations. The error message you’ll get will be different from what you posted here though.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.