[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Set/difference [Back]  [Original]

Set.prototype.difference() - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

Set.prototype.difference()

Baseline 2024
Newly available

Since 2024 6, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

Set difference() .

In this article

js
difference(other)

other

Set

other Set .

(difference) .

AB={xAxB}A\setminus B = {x\in A\mid x\notin B}

     . A B  A B   . [ . A B A B .]

difference() other . this Set this . this other .

  • this other.size other.size keys() other other .
  • , this other.has(e) e .

this .

difference()

(<10) (<10) . .

js
const odds = new Set([1, 3, 5, 7, 9]);
const squares = new Set([1, 4, 9]);
console.log(odds.difference(squares)); // Set(3) { 3, 5, 7 }

Specification
ECMAScript 2027 LanguageSpecification
# sec-set.prototype.difference


Web Proxy Viewer  |  New URL  |  Original Page