Jx
This module provides utilities for interfacing with JavaScript values.
Example:
(* Bind the global document value. *)
let document = Jx.global "document"
let get_element_by_id id =
(* Define decoder for the return type. *)
let return = Jx.Decoder.(nullable js) in
(* Bind the method call: document.getElementById(id). *)
Jx.Obj.call1 document "getElementById" Jx.Encoder.string id ~return
val null : js
The JavaScript null
value.
val undefined : js
The JavaScript undefined
value.
An exception raised when an unexpected undefined
property is encountered.
See debugger
.
See console.log
.
val is_null : js -> bool
is_null js
is js == null
.
val is_undefined : js -> bool
is_undefined js
is js == undefined
.
val is_defined : js -> bool
is_defined js
is js != undefined
.
val is_number : js -> bool
val is_int : js -> bool
val is_boolean : js -> bool
val is_string : js -> bool
val is_object : js -> bool
See instanceof
.
val global : string -> js
global name
is globalThis[name]
. If this evaluates to undefined
, Undefined_property
is raised.
val global_this : js
See globalThis
.
module Encoder : sig ... end
module Decoder : sig ... end
module Obj : sig ... end
module Array : sig ... end
module Fun : sig ... end