September 2017
Intermediate to advanced
216 pages
6h 8m
English
Now let's try pushing multiple values to a list:
const myList = List.of(1, 2, 3);const myChangedList = myList .push(4) .push(5, 6) .push(7, 8) .push(9);console.log('myList', myList.toJS());// -> myList [ 1, 2, 3 ]console.log('myChangedList', myChangedList);// -> myChangedList List [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
Here, the first three calls to push() create intermediary lists—you don't actually use them for anything other than as steps for building a new list. The final call to push() produces the value that ends up in myChangedList. You can see that push() accepts multiple values to add to the list. Of course, it would be better to make one call instead of four where possible. However, this isn't always possible ...
Read now
Unlock full access