September 2017
Intermediate to advanced
216 pages
6h 8m
English
Merging lists of lists is a lot like merging lists of maps. The values from the second list override the values from the first list:
const myList1 = List.of( List.of(1, 2), List.of(3, 4));const myList2 = List.of( List.of(11, 21, 3), List.of(33, 44, 5));const myMergedList = myList1.merge(myList2);console.log('myList1', myList1.toJS());// -> myList1 [ [ 1, 2 ], [ 3, 4 ] ]console.log('myList2', myList2.toJS());// -> myList2 [ [ 11, 21, 3 ], [ 33, 44, 5 ] ]console.log('myMergedList', myMergedList.toJS());// -> myMergedList [ [ 11, 21, 3 ], [ 33, 44, 5 ] ]
Instead of replacing or preserving values, we want to merge the values that have the same index. Since these are lists instead of maps, the approach is slightly different: ...
Read now
Unlock full access