BroadcastChannel.name

Baseline 2022

Newly available

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

BroadcastChannel.name は読み取り専用のプロパティで、指定されたチャンネルをその名前で一意に識別する文字列を返します。 この名前は作成時に BroadcastChannel() コンストラクターに渡されるため、読み取り専用です。

注: この機能は Web Worker 内で利用可能です。

文字列です。

js
// チャンネルに接続
const bc = new BroadcastChannel("test_channel");

// その他の操作(postMessage など)

// チャンネル名をコンソールに記録します
console.log(bc.name); // "test_channel"

// 終了したら、チャンネルから切断します
bc.close();

仕様書

Specification
HTML Standard
# dom-broadcastchannel-name-dev

ブラウザーの互換性

BCD tables only load in the browser

関連情報