Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Unable to Create New Set From Array

I am trying to create new Sets from an array but it is returning an empty object. What am I doing wrong?

const myArray = ["value1", "value2", "value3", "value1", "value2"];
const mySet = new Set(myArray);
Logger.log(mySet);

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

new Set() returns the Set object. When you want to see the value, how about the following modification?

From:

Logger.log(mySet);

To:

Logger.log([...mySet]);

or

Logger.log(Array.from(mySet));

References:

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading