[1, 10, 8].sort();
If you thought this would evaluate to
[1, 10, 8].sort() = [1, 10, 8]
Why is this? The answer:
- therefore, the Array.prototype.sort() method first applies the toString() method on each element of the array, and then sorts them in lexicographic order — also known as alphabetical sorting — as opposed to numerical order.