Javascript Array methods :
Javascript has an array of methods and properties. In this lesson, we are going to learn about JS Array properties and methods.
Array sort() method :
The array has a method called sort(), this method is used to sort the array. It means the sort() method re-arranges the array from lower order to higher order.
Ex.
console.log(wellcome to js tutorial!!!!);
let arr = [45,56,24,14,67];
console.log(arr);
arr.sort();
console.log("After sorting array : " , arr);
It will give output in console :
PS D:\practicejs> node index3.js
welcome to js tutorial!!!
[ 45, 56, 24, 14, 67 ]
After sorting array : [ 14, 24, 45, 56, 67 ]
PS D:\practicejs>
Comments
Post a Comment