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

BroadcastChannel.close()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2022년 3월⁩.

BroadcastChannel.close() 는 채널에 대한 연결을 종료하여, 객체가 가비지 컬렉션으로 처리되도록 합니다. 브라우저 입장에서 채널이 더 이상 필요하지 않다는 것을 알 수 있는 다른 방법이 없기 때문에, 이 단계는 반드시 수행해야 하는 단계입니다.

참고 : 이 기능은 Web Worker에서 사용할 수 있습니다.

구문

js
channel.close()

예제

js
// 채널에 연결
const bc = new BroadcastChannel("test_channel");

// postMessage 등의 동작들...

// 완료되면 채널 연결 해제
bc.close();

명세서

Specification
HTML
# dom-broadcastchannel-close-dev

브라우저 호환성

같이 보기