intersection(secondSet) { const intersectionSet = new Set() const firstSetValues = this.values() const secondSetValues = secondSet.values() const allValues = [...firstSetValues, ...secondSetValues] allValues.forEach( value => secondSet.has(value) && this.has(value) && intersectionSet.add(value), ) return intersectionSet }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter