javascript can't pass string to my function

I was calling my function with parameter date string like “24/08/2017” and my function is

function openEdit(dateid){
    alert(dateid);
    }

And it’s return 0.00013882002974714924. The function call is like

<button onclick="openEdit(datestring)"></button>

Use this if you are using a server side technology

<button onclick="openEdit(/''+datestring+'/')"></button> 

or

<button onclick="openEdit('<yourdate>')"></button>

You just need to add some quotes around the datestring

function openEdit(dateid){
  var temp = new Date(dateid);
  alert(temp);
}

Try this.

You appear to be putting the date in with no delimiters:

<button onclick="openEdit(24/08/2017)"></button>

That does the math 24/08/2017 and passes the result, 0.001487357461576599, into the function.

Put quotes around it:

<button onclick="openEdit('24/08/2017')"></button>

You’re probably doing this with a server-side technology, perhaps PHP. If it’s PHP, then presumably you’re using echo or similar:

echo '<button onclick="openEdit(' . datestring . ')"></button>';

If so, just put the quotes on either side:

echo '<button onclick="openEdit(/'' . datestring . '/')"></button>';

You have to convert the date to a string it actually performs the / operation.You can convert to string by using toString() method in JS.