Module Js.​Unsafe

module Unsafe : sig..end

Unsafe Javascript operations


val variable : string -> 'a

Access a Javascript variable. variable "foo" will return the current value of variable foo.

type any

Top type. Used for putting values of different types in a same array.

val inject : 'a -> any

Coercion to top type.

val coerce : < .. > Js.t -> < .. > Js.t

Unsafe coercion between to Javascript objects.

val get : 'a -> 'b -> 'c

Get the value of an object property. The expression get o s returns the value of property s of object o.

val set : 'a -> 'b -> 'c -> unit

Set an object property. The expression set o s v set the property s of object o to value v.

val delete : 'a -> 'b -> unit

Delete an object property. The expression delete o s deletes property s of object o.

val call : 'a -> 'b -> any array -> 'c

Performs a Javascript function call. The expression call f o a calls the Javascript function f with the arguments given by the array o, and binding this to o.

val fun_call : 'a -> any array -> 'b

Performs a Javascript function call. The expression fun_call f a calls the Javascript function f with the arguments given by the array o.

val meth_call : 'a -> string -> any array -> 'b

Performs a Javascript method call. The expression meth_call o m a calls the Javascript method m of object o with the arguments given by the array a.

val new_obj : 'a -> any array -> 'b

Create a Javascript object. The expression new_obj c a creates a Javascript object with constructor c using the arguments given by the array a.

val obj : (string * any) array -> 'a

Creates a Javascript literal object. The expression obj a creates a Javascript object whose fields are given by the array a

val pure_expr : (unit -> 'a) -> 'a

Asserts that an expression is pure, and can therefore be optimized away by the compiler if unused.

val eval_string : string -> 'a

Evaluate Javascript code

val expr : string -> 'a

expr e will parse the JavaScript expression e if e is available at compile time or will failback to a runtime evaluation. See eval_string

val global : < .. > Js.t

Javascript global object