How will you sort an array using javascript?

 Posted by Rajni.Shekhar on 4/12/2012 | Category: JavaScript Interview questions | Views: 1739 | Points: 40
Answer:

Using sort() function.

[code]var arr=new Array();
arr[0]="dot";
arr[1]="net";
arr[2]="funda";

arr.sort();
document.write(arr[0] + " " + arr[1] + " " + arr[2] );

output will be
dot funda net

[/code]


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response