Very good practice to write 'pure' (ie non-mutating) functions dealing with your arrays :+1:
Some of the calls to cloneArrayOfObjects are redundant, since Array.concat() and Array.filter() return new arrays. Array.sort() doesn't, though.
Your code has the added bonus that it also clones, rather than copies reference to, each of the objects within the array. As these objects are not mutated by your functions, this is also unnecessary in this case.
However, what I've written all takes thinking about and planning and being very sure of your conclusions.
If in doubt, clone everything!
Very good practice to write 'pure' (ie non-mutating) functions dealing with your arrays :+1:
Some of the calls to
cloneArrayOfObjects
are redundant, sinceArray.concat()
andArray.filter()
return new arrays.Array.sort()
doesn't, though.Your code has the added bonus that it also clones, rather than copies reference to, each of the objects within the array. As these objects are not mutated by your functions, this is also unnecessary in this case.
However, what I've written all takes thinking about and planning and being very sure of your conclusions. If in doubt, clone everything!