JavaScript ES2023??
JavaScript ES2023??
@webbysaif
toSorted():
The toSorted() method of Array
instances is the copying version
of the sort() method. It returns a
new array without modifying
original array with the elements
sorted in ascending order.
toReversed():
toSpliced():
with():
The with() method is the copying version of using bracket notation to set the value of
an element at a given index in an array. Unlike bracket notation, it doesn't mutate the
array it's called upon.
It returns a new array, allowing you to chain array methods while performing
manipulations without worrying about mutating the original array
Without the .with() method, you would need to copy the array first, mutate the copy,
and then sort the copy
Bonus
useful?
Saif Mujawar
@webbysaif