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.
b=[...a] for instance would create a deep copy, meaning it really allocate new space withing the memory with the copied data.
b=a just copy the reference points, so if you alter or access the memory by using either reference a or b it will change the same data in the same location.
There are more to shallow and deep copies in javascript. For instance, if you have a nested array on the copied array, b=[...a] will not deep copy it. It will deep copy the memory reference to the nested array, but the data of such array in the memory is still the same in either a or b.
Hope I helped!
Have a nice video about the theme!
https://www.youtube.com/watch?v=EeZBKv34mm4
The time I was ready to submit my solution, I thought this kata should be ranked as 4 kyu. However, after reading the cleverest solution, I realize I still need to learn more algorithm and method.
It means if 0 comes after 9, 0 can be seemed as 10, but 1 shouldn't come after 10
This Kata reminds me of a question:
a=[1,2,3]
b=a
a.pop()
The result of b is [1,2]
So how can we store a list?