DevTips Daily: The JavaScript array sort method (how to sort in JavaScript)

preview_player
Показать описание
⭐️ Check out more DevTips Daily ⭐️

#devtipsdaily Channel Handle @codebubb
Рекомендации по теме
Комментарии
Автор

this video finally made me understand the - between parameters lol, ive used it before but did not understood why it worked lol, id like to mention the following tho:
if the numbers are over 9 then the sort without parameters will sort 10 as 1 for example:
arr = [5, 9, 10, 20]
arr.sort() // [10, 20, 5, 9]
so in those cases, we need the parameters such as: arr.sort(num1, num2 => num1 - num2)

juancamacho