Ad
  • Custom User Avatar

    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

  • Default User Avatar

    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.

  • Default User Avatar

    It means if 0 comes after 9, 0 can be seemed as 10, but 1 shouldn't come after 10

  • Default User Avatar

    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?