Loading topic
sort, splice, and assigning to an index with brackets. This chapter shows how that mutatio2 min readsort and splice, arrow functions, and the difference between primitive values and object references.2 min readArray.prototype.sort before, and can read arrow functions. Everything here applies to both sort and toSorted, because the two methods take the same optional comparator and follow the same ordering rules.2 min readArray.prototype.sort behaves, how to write arrow functions, and how primitive values differ from object references.2 min readArray.prototype.splice works and what its start, deleteCount, and items arguments do. You should also know that splice changes the array you call it on.2 min readarr[i] = value) changes an array, and how primitive values differ from object references. Earlier chapters covered why mutation causes bugs and how toSorted and toSpliced work. This one covers the third copying met2 min readwith(index, value) returns a copy with one element replaced. Here we look at the index rules that with follows. They differ from bracket assignment in ways that matter when the index comes from user input or a calculation.2 min readArray.prototype.reverse, and that you understand the difference between a primitive value and an object reference. ES2023 added four copying methods together. You have already seen toSorted, toSpliced, an2 min readtoSorted, toSpliced, and with return new arrays. It also assumes you understand that JavaScript stores objects by reference: a variable holding an object holds a pointer to it, not the object itself.2 min readtoSorted, toSpliced, and with from the earlier chapters. It also assumes you know that map and filter return new arrays. Each copying method returns a fresh array, so you can call the next method directly on that result. This lets you write a sequence 2 min readtoSorted, toSpliced, and with work, and what a shallow copy shares with its original. It also assumes basic familiarity with React's useState or a Redux reducer. You do not need either library to run the examples, because they are plain functions.2 min readsort, splice, and reverse mutate an array. Here you will check whether a runtime has the ES2023 methods and write fallbacks that give the same results when it does not.2 min readtoSorted, toSpliced, and with work from the earlier chapters. You should also know that an array index can exist with the value undefined or be missing entirely.2 min readtoSorted, toSpliced, and with behave on ordinary arrays. You also need to know how Function.prototype.call sets this, and what an Array subclass created with class ... extends Array is.2 min readtoSorted, toSpliced, and with on regular arrays. It also assumes you know what a typed array is: a fixed-length view of binary data, such as Uint8Array or Float64Array, that holds numbers of a single type.2 min read