Does Javascript slice method return a shallow copy?

前端 未结 3 1777
耶瑟儿~
耶瑟儿~ 2020-12-04 01:51

In a Mozilla developer translated Korean lang says \'slice method\' returns a new array copied shallowly.

so I tested my code.

var animals = [\'ant\'         


        
3条回答
  •  感动是毒
    2020-12-04 02:25

    The slice method doesn't change the original array or string. It only cuts a portion of the original string or array and returns it as a copy. For more understanding of it, kindly check this video below: https://youtu.be/mUH8hPQfMbg [Slice method made easy for absolute beginners]

提交回复
热议问题