A RetroSearch Logo

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

Search Query:

Showing content from https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/WeakSet below:

WeakSet() 생성자 - JavaScript | MDN

WeakSet() 생성자

Baseline Widely available

WeakSet() 생성자는 WeakSet 객체를 생성합니다.

구문
new WeakSet()
new WeakSet(iterable)

참고: WeakSet()은 오직 new로만 생성할 수 있습니다. new 없이 호출을 시도하면 TypeError가 발생합니다.

매개변수
iterable Optional

만약 순회 가능한 객체가 매개변수로 주어진다면, 모든 해당 객체가 새로운 WeakSet에 추가됩니다. null은 undefined로 취급합니다.

예제 WeakSet 객체 사용하기
const ws = new WeakSet();
const foo = {};
const bar = {};

ws.add(foo);
ws.add(bar);

ws.has(foo); // true
ws.has(bar); // true

ws.delete(foo); // foo 를 set에서 제거
ws.has(foo); // false, foo는 이미 삭제되었습니다
ws.has(bar); // true, bar는 유지 중입니다

명심하실 점은 foo !== bar라는 점입니다. 둘은 서로 비슷한 객체지만 같은 객체가 아닙니다. 그래서 두 객체 모두 set에 추가 가능합니다.

명세서 브라우저 호환성 같이 보기

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