W3cubDocs

/Web APIs

HighlightRegistry: has() method

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The has() method of the HighlightRegistry interface returns a boolean indicating whether or not a Highlight object with the specified name exists in the registry.

HighlightRegistry is a Map-like object, so this is similar to using Map.has().

Syntax

js

has(name)

Parameters

name

The name of the Highlight object to test for presence in the registry.

Return value

Returns true if a highlight with the specified name exists in the registry; otherwise false.

Examples

js

const fooHighlight = new Highlight();
CSS.highlights.set("foo", fooHighlight);

myHighlight.has("foo"); // true
myHighlight.has("bar"); // false

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
has 105 105 preview No 91 No 105 105 No 72 No 20.0

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HighlightRegistry/has