DocsPlaygroundBlogCommunityPackages
  • Playground
  • Blog
  • Community
  • Packages
  • X
  • Bluesky
  • GitHub
  • Forum
Language ManualAPISyntax LookupReact
Overview
Js
  • t
    t
    D
  • v
    globalThis
    D
  • t
    null
    D
  • t
    undefined
    D
  • t
    nullable
    D
  • t
    null_undefined
    D
  • v
    toOption
  • v
    undefinedToOption
    D
  • v
    nullToOption
    D
  • v
    isNullable
    D
  • v
    import
    D
  • v
    testAny
    D
  • t
    promise
    D
  • v
    null
    D
  • v
    undefined
    D
  • v
    typeof
    D
  • v
    log
    D
  • v
    log2
    D
  • v
    log3
    D
  • v
    log4
    D
  • v
    logMany
    D
  • v
    eqNull
    D
  • v
    eqUndefined
    D
  • v
    eqNullable
    D
  • v
    unsafe_lt
    D
  • v
    unsafe_le
    D
  • v
    unsafe_gt
    D
  • v
    unsafe_ge
    D
submodules
  • Array
  • Array2
  • BigInt
  • Blob
  • Console
  • Date
  • Dict
  • Exn
  • File
  • Float
  • Global
  • Int
  • Json
    • Kind
  • Map
  • Math
  • Null
  • Null_undefined
  • Nullable
  • Obj
  • Option
  • Promise
  • Promise2
  • Re
  • Result
  • Set
  • String
  • String2
  • TypedArray2
    • DataView
    • Float64Array
    • Float32Array
    • Uint32Array
    • Int32Array
    • Uint16Array
    • Int16Array
    • Uint8ClampedArray
    • Uint8Array
    • Int8Array
    • ArrayBuffer
    Typed_array
    • DataView
    • Float64_array
    • Float64Array
    • Float32_array
    • Float32Array
    • Uint32Array
    • Int32_array
    • Int32Array
    • Uint16Array
    • Int16Array
    • Uint8ClampedArray
    • Uint8Array
    • Int8Array
    • S
    • ArrayBuffer
    • Type
  • Types
  • Undefined
  • WeakMap
  • WeakSet
  • Docs / API / Js

    Js

    The Js module mostly contains ReScript bindings to standard JavaScript APIs like console.log, or the JavaScript String, Date, and Promise classes.

    It is meant as a zero-abstraction interop layer and directly exposes JavaScript functions as they are. If you can find your API in this module, prefer this over an equivalent Belt helper. For example, prefer Js.Array2 over Belt.Array

    Argument Order

    For historical reasons, some APIs in the Js namespace (e.g. Js.String) are using the data-last argument order whereas others (e.g. Js.Date) are using data-first.

    For more information about these argument orders and the trade-offs between them, see this blog post.

    Eventually, all modules in the Js namespace are going to be migrated to data-first though.

    Js.Xxx2 Modules

    Prefer Js.Array2 over Js.Array, Js.String2 over Js.String, etc. The latters are old modules.

    t

    Deprecated

    This has been deprecated and will be removed in v13. Use the {..} type directly instead.

    RESCRIPT
    type t<'a> = 'a constraint 'a = {..}

    JS object type

    globalThis

    Deprecated

    RESCRIPT
    let globalThis: t<{..}>

    JS global object reference

    null

    Deprecated

    RESCRIPT
    @unboxed type null<'a> = Js_null.t<'a> = Value('a) | @as(null) Null

    undefined

    Deprecated

    This has been deprecated and will be removed in v13.

    RESCRIPT
    type undefined<'a> = Js_undefined.t<'a>

    nullable

    Deprecated

    RESCRIPT
    @unboxed type nullable<'a> = Js_null_undefined.t<'a> = | Value('a) | @as(null) Null | @as(undefined) Undefined

    null_undefined

    Deprecated

    RESCRIPT
    type null_undefined<'a> = nullable<'a>

    toOption

    RESCRIPT
    let toOption: nullable<'a> => option<'a>

    undefinedToOption

    Deprecated

    RESCRIPT
    let undefinedToOption: undefined<'a> => option<'a>

    nullToOption

    Deprecated

    RESCRIPT
    let nullToOption: null<'a> => option<'a>

    isNullable

    Deprecated

    RESCRIPT
    let isNullable: nullable<'a> => bool

    import

    Deprecated

    RESCRIPT
    let import: 'a => promise<'a>

    testAny

    Deprecated

    RESCRIPT
    let testAny: 'a => bool

    The same as {!test} except that it is more permissive on the types of input

    promise

    Deprecated

    This is deprecated and will be removed in v13. Use the promise type directly instead.

    RESCRIPT
    type promise<+'a, +'e>

    The promise type, defined here for interoperation across packages.

    null

    Deprecated

    RESCRIPT
    let null: null<'a>

    The same as empty in Js.Null. Compiles to null.

    undefined

    Deprecated

    RESCRIPT
    let undefined: undefined<'a>

    The same as empty Js.Undefined. Compiles to undefined.

    typeof

    Deprecated

    RESCRIPT
    let typeof: 'a => string

    typeof x will be compiled as typeof x in JS. Please consider functions in Js.Types for a type safe way of reflection.

    log

    Deprecated

    RESCRIPT
    let log: 'a => unit

    Equivalent to console.log any value.

    log2

    Deprecated

    RESCRIPT
    let log2: ('a, 'b) => unit

    log3

    Deprecated

    RESCRIPT
    let log3: ('a, 'b, 'c) => unit

    log4

    Deprecated

    RESCRIPT
    let log4: ('a, 'b, 'c, 'd) => unit

    logMany

    Deprecated

    RESCRIPT
    let logMany: array<'a> => unit

    A convenience function to console.log more than 4 arguments

    eqNull

    Deprecated

    RESCRIPT
    let eqNull: ('a, null<'a>) => bool

    eqUndefined

    Deprecated

    RESCRIPT
    let eqUndefined: ('a, undefined<'a>) => bool

    eqNullable

    Deprecated

    RESCRIPT
    let eqNullable: ('a, nullable<'a>) => bool

    unsafe_lt

    Deprecated

    RESCRIPT
    let unsafe_lt: ('a, 'a) => bool

    unsafe_lt(a, b) will be compiled as a < b. It is marked as unsafe, since it is impossible to give a proper semantics for comparision which applies to any type

    unsafe_le

    Deprecated

    RESCRIPT
    let unsafe_le: ('a, 'a) => bool

    unsafe_le(a, b) will be compiled as a <= b. See also Js.unsafe_lt.

    unsafe_gt

    Deprecated

    RESCRIPT
    let unsafe_gt: ('a, 'a) => bool

    unsafe_gt(a, b) will be compiled as a > b. See also Js.unsafe_lt.

    unsafe_ge

    Deprecated

    RESCRIPT
    let unsafe_ge: ('a, 'a) => bool

    unsafe_ge(a, b) will be compiled as a >= b. See also Js.unsafe_lt.

    Types and values
    • t
      t
      D
    • v
      globalThis
      D
    • t
      null
      D
    • t
      undefined
      D
    • t
      nullable
      D
    • t
      null_undefined
      D
    • v
      toOption
    • v
      undefinedToOption
      D
    • v
      nullToOption
      D
    • v
      isNullable
      D
    • v
      import
      D
    • v
      testAny
      D
    • t
      promise
      D
    • v
      null
      D
    • v
      undefined
      D
    • v
      typeof
      D
    • v
      log
      D
    • v
      log2
      D
    • v
      log3
      D
    • v
      log4
      D
    • v
      logMany
      D
    • v
      eqNull
      D
    • v
      eqUndefined
      D
    • v
      eqNullable
      D
    • v
      unsafe_lt
      D
    • v
      unsafe_le
      D
    • v
      unsafe_gt
      D
    • v
      unsafe_ge
      D

    © 2025 The ReScript Project

    About
    • Community
    • ReScript Association
    Find us on