JavaScript · Middle · Question 53 of 75

How does arr.toSorted() differ from arr.sort()?

Explanation

ES2023 added non-mutating copies: toSorted, toReversed, toSpliced and with(index, value). They are handy for React/Redux state where mutation is a bug.

Further reading

Problem with a question

JavaScript · Middle · question 53

Test yourself

Take the JavaScript · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz