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

Answer: 
You can use the following function specified, 1 date and 2 the date separator (optional)
The date will be returned in the desired format.

```
const setFormatDDMMYYYYtoMMDDYYYY = (date, separator = '/') => {
  const [day, month, year] = date.split('/');
  return month + separator + day + separator + year;
};

```
Try this, it works for me:

```
var fechaLatinFormat= "05-10-2016";//octuber 5, 2016 - octubre 5 del 2016
var datePieces = fechaLatinFormat.split("-"); 
var preFinalDate = new Date(parseInt(datePieces[2]), parseInt(datePieces[1]) - 1, parseInt(datePieces[0]));    
console.log(preFinalDate.format("mm-dd-yyyy")); 

```

Or:

```
var fechaLatinFormat= "05-10-2016";//octuber 5, 2016 - octubre 5 del 2016
var datePieces = fechaLatinFormat.split("-"); 
var preFinalDate = [datePieces[1] , datePieces[0] , datePieces[2]];
console.log(preFinalDate.join("-"));

```