Question · JavaScript and TypeScript course · Module 5: Advanced JavaScript
Non-Mutating Array Methods
How does toSorted() differ from sort() in JavaScript?
Answer options
- toSorted() only sorts numbers, sort() sorts everything
- toSorted() sorts faster than sort()
- There is no difference, they are aliases
- toSorted() returns a new sorted array without modifying the original, sort() modifies the original array
You can check the correct answer by solving this task in the CodeWorlds game.