The creation of pure functions is a frequent use-case for this.Ĭonsider a function that adds a URL to the list of bookmarks and returns the updated list as an example. const arr = Ĭonst newArray = arr.slice() // Duplicate the whole arrayīy calling slice without the start and end arguments, you can make a shallow copy of the entire array. If that object is changed later, the changes will show up in both the original and new arrays.Įxamples of frequent usage 1. As a result, the original and new arrays both refer to the same object.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |