Reference · Browser

js_has

signature
js_has(str) -> bool

What it does

Whether the page has a feature, by its dotted name, without calling it: true if each part of "navigator.vibrate" is there, false if any is not. js("navigator.vibrate") would call it; this only looks. On the server, where there is no page, it is false.

Examples

in a program
component Buzz() {    state can = false    can = js_has("navigator.vibrate")    <button disabled={!can} @click={() => { js("navigator.vibrate", 200) }}>Buzz</button>}
print(js_has("navigator.vibrate"), js_has("no.such.thing"))
output
false false

Edge cases

Errors

The name must be text: anything else is an error.

Chaining

"Notification" | js_has reads as js_has("Notification").

See also

js, js_new, platform

Thread
2Useful? Like it, or add to its thread below.

Thread 0 posts

On js_has(): questions, tips, corrections, and code that uses it.

No posts yet. The first one opens the thread.

    Edit this page on GitHub · every example's output was made by running it (tools/refcheck.mjs) · questions on Discord or r/quillo