September 2017
Intermediate to advanced
216 pages
6h 8m
English
You can create new sequences by passing the Seq() constructor JavaScript arrays or objects, as follows:
import { Seq } from 'immutable';const myIndexedSeq = Seq([1, 2, 3]);const myKeyedSeq = Seq({ one: 1, two: 2, three: 3 });console.log('myIndexedSeq', myIndexedSeq.toJS());// -> myIndexedSeq [ 1, 2, 3 ]console.log('myKeyedSeq', myKeyedSeq.toJS());// -> myKeyedSeq { one: 1, two: 2, three: 3 }
There are actually two types of sequence collections: Seq.Indexed and Seq.Keyed. The Seq() constructor, which is really just a function due to the absence of the new keyword, will return the correct type of collection depending on what's passed to it.
Read now
Unlock full access