Using a Set seems like a good idea but in js when you add arrays to a Set, it checks them by reference, not by value. So even if two arrays have the same numbers, they are considered different if they are different objects.
That's why when you do coordinateSet.has([1,2]), it returns false, even though [1,2] is in the set. Because [1,2] is a new array.
Common way to fix this is to convert the coordinates to strings, like "1,2", and store those in the Set. Then you can check if the Set has "1,2". Feels like a hack, but it's a common in js.
js doesn't have immutable tuples like some other languages. So using arrays or objects won't solve the problem unless you can ensure you're using the same instances.
Another option is to create a unique key for each coordinate. e.g. you combine the x and y values into a single number or string that uniquely represents the coordinate.
Using strings as keys is simple and works well. It's also efficient because string comparisons are fast.