Please see below script. I am testing it using Chrome.
var items = new Set() var arr = [1,2,3,4]; items.add(arr); console.log(items); // Set {[1, 2, 3, 4]} items.add([5,6,7,8]); console.log(items); // Set {[1, 2, 3, 4], [5, 6, 7, 8]} for (let item of items) console.log(typeof item); //object, object console.log(items.has(arr)); // true console.log(items.has([5,6,7,8])); //false items.add([1,2,3,4]); console.log(items); // Set {[1, 2, 3, 4], [5, 6, 7, 8], [1, 2, 3, 4]}
- Why does it return false in
items.has([5,6,7,8]) ? - Why does this allow duplicate values? I thought: "The set is in an ordered list of values ββthat cannot contain duplicates"
- How to access the array added by
items.add([5,6,7,8]) ?
source share