JavaScript-ni saralash massivlari
❮ OldingiKeyingi ❯
sort()Usuli Alifbo tartibida bir qator tartiblaydi:
Misol
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.sort(); // Sorts the elements of fruits
O'zingiz sinab ko'ring »
reverse()Usuli bir qator elementlar bilan o'zgartiradi.
Siz massivni kamayish tartibida saralash uchun foydalanishingiz mumkin:
Misol
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.sort(); // First sort the elements of fruits
fruits.reverse(); // Then reverse the order of the elements
O'zingiz sinab ko'ring »
Do'stlaringiz bilan baham: |