Question: I want to convert dd/mm/yyyy to mm/dd/yyyy in javascript.

Answer: 
```
var date = "24/09/1977";
var datearray = date.split("/");

var newdate = datearray[1] + '/' + datearray[0] + '/' + datearray[2];

```

newdate will contain 09/24/1977. The split method will split the string wherever it finds a "/", so if the date string was "24/9/1977", it would still work and return 9/24/1977.
Try this example where a regular expression is used to find and switch the parts of the string: 

```
var d1 = "03/25/2011";
var d2 = d1.replace(/^(\d{1,2}\/)(\d{1,2}\/)(\d{4})$/,"$2$1$3");
alert("d1:"+d1 +"\n d2:"+d2 )

/* 
// OUTPUT

  d1: 03/25/2011
  d2: 25/03/2011

*/

```

EDIT:

I noticed that no other answer is using regular expression and I really wonder why... :)