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.
List
new
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) // truelistFromPlainSet.equals(listFromCollectionArray) // truelistFromPlainSet.equals(listFromPlainArray) // true
Optional
Generated using TypeDoc
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 thenew
keyword during construction.