A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.cdn.mozilla.net/ko/docs/Web/JavaScript/Reference/Global_Objects/Set/isSupersetOf below:

Set.prototype.isSupersetOf() - JavaScript | MDN

Set.prototype.isSupersetOf()

Baseline 2024

Newly available

Set 인스턴스의 isSupersetOf() 메서드는 하나의 Set을 받아서 주어진 Set의 모든 요소가 이 Set에 속하는지 여부를 가리키는 불리언을 반환합니다.

구문 매개변수
other

Set 객체 혹은 유사 Set 객체입니다.

반환 값

other Set의 모든 요소가 이 Set 안에 있을 경우 true, 그렇지 않으면 false입니다.

설명

수학적 표기법으로는 상위집합(superset)은 아래와 같이 표현할 수 있습니다.

A ⊇ B ⇔ ∀ x ∊ B , x ∊ A A\supseteq B \Leftrightarrow \forall x\in B,,x\in A

벤 다이어그램으로는 아래와 같습니다.

참고 : 초집합 관계는 완벽한 상위집합이 아닙니다. isSupersetOf()는 this과 other에 동일한 요소가 포함되어 있으면 true를 반환합니다.

isSupersetOf()는 other 매개변수로 유사 Set 객체를 받습니다. 어떠한 사용자 코드 호출없이 this에 저장된 기본 데이터를 직접 검색하기 때문에 실제 this 인스턴스여야 합니다. 그러면 그 동작은 this와 other의 크기에 따라 달라집니다.

예제 isSupersetOf() 사용하기

짝수 집합(20 미만)은 4의 배수(20 미만)의 상위집합입니다.

const evens = new Set([2, 4, 6, 8, 10, 12, 14, 16, 18]);
const fours = new Set([4, 8, 12, 16]);
console.log(evens.isSupersetOf(fours)); // true

모든 홀수(20 미만)의 집합은 2가 소수는 맞지만 홀수는 아니므로 소수(20 미만)의 상위집합이 아닙니다.

const primes = new Set([2, 3, 5, 7, 11, 13, 17, 19]);
const odds = new Set([3, 5, 7, 9, 11, 13, 15, 17, 19]);
console.log(odds.isSupersetOf(primes)); // false

서로 동일한 집합은 서로에 대해 상위집합 관계가 성립합니다.

const set1 = new Set([1, 2, 3]);
const set2 = new Set([1, 2, 3]);
console.log(set1.isSupersetOf(set2)); // true
console.log(set2.isSupersetOf(set1)); // true
명세서 브라우저 호환성 같이 보기

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4