![]() The thisArg argument (defaults to undefined) will be used as the this value when calling callbackFn. What callbackFn is expected to return depends on the array method that was called. The array that the method was called upon. The index of the current element being processed in the array. ![]() The current element being processed in the array. Where callbackFn takes three arguments: element The following table lists the methods that mutate the original array, and the corresponding non-mutating alternative: Mutating methodĪn easy way to change a mutating method into a non-mutating alternative is to use the spread syntax or slice() to create a copy first: The following methods always create new arrays with the Array base constructor: toReversed(), toSorted(), toSpliced(), and with(). The following methods create new arrays by accessing nstructor to determine the constructor to use: concat(), filter(), flat(), flatMap(), map(), slice(), and splice() (to construct the array of removed elements that's returned). Other methods mutate the array that the method was called on, in which case their return value differs depending on the method: sometimes a reference to the same array, sometimes the length of the new array.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |