I have a Vanilla JS array, containing numbers as strings.
const stringArray = ['1', '2', '3', '4'];
If I want to convert all the numbers in the array to intger I simply do
const integerArray = stringArray.map(Number);
Now, I have an Immutable JS List
const immutableListStrings = Immutable.List(stringArray);
Using
immutableListStrings.map(Number);
does not convert the strings to integer. Why is that?
Array.prototype.mapdoes not change the array in place..mapreturns a newList(immutable-js.github.io/immutable-js/docs/#/List/map). In fact, the whole point of the library is to create/use immutable data structures so operations usually return a new value.