• Create a new immutable List containing the values of the provided collection-like.

    Note: List is a factory function and not a class, and does not use the new keyword during construction.

    const { List, Set } = require('immutable')

    const emptyList = List()
    // List []

    const plainArray = [ 1, 2, 3, 4 ]
    const listFromPlainArray = List(plainArray)
    // List [ 1, 2, 3, 4 ]

    const plainSet = Set([ 1, 2, 3, 4 ])
    const listFromPlainSet = List(plainSet)
    // List [ 1, 2, 3, 4 ]

    const arrayIterator = plainArray[Symbol.iterator]()
    const listFromCollectionArray = List(arrayIterator)
    // List [ 1, 2, 3, 4 ]

    listFromPlainArray.equals(listFromCollectionArray) // true
    listFromPlainSet.equals(listFromCollectionArray) // true
    listFromPlainSet.equals(listFromPlainArray) // true

    Type Parameters

    • T

    Parameters

    Returns <internal>.List<T>

Generated using TypeDoc