Reference · Browser
js_has
signature
js_has(str) -> boolWhat 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 falseEdge cases
- A property that is there with the value
undefinedcounts as not there. - A part that is
nullends it:js_has("a.b")withanull isfalse, not an error. - It reads only what is reached by name from the page's globals, as
jsdoes.
Errors
The name must be text: anything else is an error.
Chaining
"Notification" | js_has reads as js_has("Notification").
See also
Thread
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