'How convert dd/mm/yyy to date using javascript?

How do I convert the value 24/05/2016 (typeof(24/05/2016) is number) for a Date using JavaScript?

While performing the following error occurs:

transactionDateAsString.split is not a function"

var transactionDateAsString = 24/05/2015;
var parts = transactionDateAsString.split("/");
var dudu = parts + '';
var date = new Date(dudu[2], dudu[1] - 1, dudu[0]);
console.log(date);


Solution 1:[1]

Not sure why you are adding an empty string at some point. This is how it should be:

var transactionDateAsString = '24/05/2015';
var parts = transactionDateAsString.split("/");
var date = new Date(parts[2],parts[1]-1,parts[0]);
alert(date);

Also note the quotes around the date as string.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 laurent