Q. Which of the following functions sorts the elements of an array?
β
Correct Answer: (B)
sort()
Explanation: sort() – Sorts the elements of an array. Example:
var letters = ['D', 'C', 'B', 'A'];
letters.sort(); //A B C D
var letters = ['D', 'C', 'B', 'A'];
letters.sort(); //A B C D