Mapping to new lists of maps
You don't always want to transform lists of maps into lists of simple values. Sometimes, you want to add new keys, remove existing keys, or both.
Creating new keys
Let's revisit the earlier example where we mapped a list of names. We'll do the same thing here, except that we'll add the resulting string to each map as a new key-value pair:
const capitalize = s => `${s.charAt(0).toUpperCase()}${s.slice(1)}`; const myList = List.of( Map.of('first', 'joe', 'last', 'brown', 'age', 45), Map.of('first', 'john', 'last', 'smith', 'age', 32), Map.of('first', 'mary', 'last', 'wise', 'age', 56) ); const myMappedList = myList.map( v => v.set('name', [ capitalize(v.get('first')), capitalize(v.get('last')) ].join(' ')) ); console.log('myList', myList.toJS()); // -> myList [ { first: 'joe', last: 'brown', age: 45 }, // -> { first: 'john', last: 'smith', age: 32 }, // -> { first: 'mary', last: 'wise', age: 56 } ] console.log...