Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
slice
is an option to make a shallow copy.another modern way (ES6) is
Array.from(age)
o with spread[...ages]
Nothing says the inmutability of
age
needs to be preserved. Actually it doesn't.@mreza-dehghani: you can use a slice to preserve the original array:
_data = ages.slice().sort(...
so what is your solution??
Array.sort
makes in-place operations so inmutability ofages
array is not guaranteed. It implies having side effects after executing function.