Highlight: clear() メソッド
Baseline 2025Newly available
Since June 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
clear()
は Highlight
インターフェイスのメソッドで、 Highlight
オブジェクトからすべての Range
オブジェクトを除去します。
Highlight
は Set
風オブジェクトですので、これは Set.clear()
を使うのと似ています。
構文
js
clear()
返値
なし (undefined
)。
例
次のコードスニペットは、2 つの範囲を持つ新しいハイライトを作成し、それをクリアする方法を示しています。
js
const highlight = new Highlight(range1, range2);
console.log(highlight.size); // 2
highlight.clear();
console.log(highlight.size); // 0
仕様書
Specification |
---|
ECMAScript® 2026 Language Specification # sec-set.prototype.clear |