This is the latest docs version
Quick Links
  • -Overview
  • -Language Features
  • -JS Interop
  • -Build System
Documentation
Language Manual
Reference for all language features
ReScript & React
First class bindings for ReactJS
GenType
Seamless TypeScript integration
Reanalyze
Dead Code & Termination analysis
Exploration
Packages
Explore third party libraries and bindings
Syntax Lookup
Discover all syntax constructs
APIPlaygroundBlogCommunity
  • Playground
  • Blog
  • Community
  • X
  • Bluesky
  • GitHub
  • Forum
Js Module
Overview
Js
submodules
  • Array
  • Array2
  • BigInt
  • Blob
  • Console
  • Date
  • Dict
  • Exn
  • File
  • Float
  • Global
  • Int
  • Json
    • Kind
  • List
  • 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
  • Vector
    • t
      t
    • v
      filterInPlace
    • v
      empty
    • v
      pushBack
    • v
      copy
    • v
      memByRef
    • v
      iter
    • v
      iteri
    • v
      toList
    • v
      map
    • v
      mapi
    • v
      foldLeft
    • v
      foldRight
    • v
      length
    • v
      get
    • v
      set
    • v
      make
    • v
      init
    • v
      append
    • v
      unsafe_get
    • v
      unsafe_set
  • WeakMap
  • WeakSet
  • API / Js / Vector

    Vector

    Provides bindings for JS Vector

    t

    RESCRIPT
    type t<'a> = array<'a>

    filterInPlace

    RESCRIPT
    let filterInPlace: ('a => bool, t<'a>) => unit

    empty

    RESCRIPT
    let empty: t<'a> => unit

    pushBack

    RESCRIPT
    let pushBack: ('a, t<'a>) => unit

    copy

    RESCRIPT
    let copy: t<'a> => t<'a>

    shallow copy

    memByRef

    RESCRIPT
    let memByRef: ('a, t<'a>) => bool

    iter

    RESCRIPT
    let iter: ('a => unit, t<'a>) => unit

    iteri

    RESCRIPT
    let iteri: ((int, 'a) => unit, t<'a>) => unit

    toList

    RESCRIPT
    let toList: t<'a> => list<'a>

    map

    RESCRIPT
    let map: ('a => 'b, t<'a>) => t<'b>

    mapi

    RESCRIPT
    let mapi: ((int, 'a) => 'b, t<'a>) => t<'b>

    foldLeft

    RESCRIPT
    let foldLeft: (('a, 'b) => 'a, 'a, t<'b>) => 'a

    foldRight

    RESCRIPT
    let foldRight: (('b, 'a) => 'a, t<'b>, 'a) => 'a

    length

    RESCRIPT
    let length: t<'a> => int

    Return the length (number of elements) of the given array.

    get

    RESCRIPT
    let get: (t<'a>, int) => 'a

    Vector.get(a, n) returns the element number n of vector a. The first element has number 0. The last element has number Vector.length(a) - 1. You can also write a[n] instead of Vector.get(a, n). Raise Invalid_argument "index out of bounds" if n is outside the range 0 to (Array.length(a) - 1).

    set

    RESCRIPT
    let set: (t<'a>, int, 'a) => unit

    Vector.set(a, n, x) modifies vector a in place, replacing element number n with x. Raise Invalid_argument "index out of bounds" if n is outside the range 0 to Array.length(a) - 1.

    make

    RESCRIPT
    let make: (int, 'a) => t<'a>

    Vector.make(n, x) returns a fresh vector of length n, initialized with x. All the elements of this new vector are initially physically equal to x (in the sense of the == predicate). Consequently, if x is mutable, it is shared among all elements of the array, and modifying x through one of the array entries will modify all other entries at the same time. Raise Invalid_argument if n < 0 or n > Sys.max_array_length. If the value of x is a floating-point number, then the maximum size is only Sys.max_array_length / 2.

    init

    RESCRIPT
    let init: (int, int => 'a) => t<'a>

    Raises RangeError when n is negative. n : size

    append

    RESCRIPT
    let append: ('a, t<'a>) => t<'a>

    append(x, a) returns a fresh vector with x appended to a.

    unsafe_get

    RESCRIPT
    let unsafe_get: (t<'a>, int) => 'a

    unsafe_set

    RESCRIPT
    let unsafe_set: (t<'a>, int, 'a) => unit
    Types and values
    • t
      t
    • v
      filterInPlace
    • v
      empty
    • v
      pushBack
    • v
      copy
    • v
      memByRef
    • v
      iter
    • v
      iteri
    • v
      toList
    • v
      map
    • v
      mapi
    • v
      foldLeft
    • v
      foldRight
    • v
      length
    • v
      get
    • v
      set
    • v
      make
    • v
      init
    • v
      append
    • v
      unsafe_get
    • v
      unsafe_set

    © 2025 The ReScript Project

    Software and assets distribution powered by KeyCDN.

    About
    • Community
    • ReScript Association
    Find us on