Sorts an array in place, with an optional comparator.
- Category: JS Array Methods Reference — part of the JavaScript Tutorial on GoCareerGo
- Read the short summary above, then check the linked docs for full syntax/behaviour
- Interview tip: be ready to explain "Array.prototype.sort()" in one sentence, then back it up with a tiny example
// Array.prototype.sort() — minimal example
console.log("Array.prototype.sort()");Tip
Quick recall: "Array.prototype.sort()" — sorts an array in place, with an optional comparator.