Reputation: 55
In all the examples of new Set it shows how to convert array to set, add to set, etc and then shows what to expect when using console.log . Is there a difference with Google Apps Script? Seems so simple, not sure what Im missing?
function myFunction() {
let arr = ["one", "two", "three"]
let setTest = new Set(arr)
Logger.log(setTest)
// Output:
//Info {}
}
The following example shows how to create a new Set from an array.
let chars = new Set(['a', 'a', 'b', 'c', 'c']);
All elements in the set must be unique therefore the chars only contains 3 distinct elements a, b and c.
console.log(chars);
Output:
Set { 'a', 'b', 'c' }
Upvotes: 0
Views: 296
Reputation: 64120
function myFunction() {
let arr = ["one", "two", "three"]
let s = new Set(arr);
let it = s.values;
Logger.log([...s])
}
Execution log
11:52:44 AM Notice Execution started
11:52:45 AM Info [one, two, three]
11:52:46 AM Notice Execution completed
Upvotes: 1