In your if-statement you are using the "new" keyword for variable endDate and curDate when you have already given both a value right above your if-block. Just use endDate and curDate as is.
Also check out how to create a date object on w3schools for the usage of new Date(). You might want to enclose your desired date in quotes, like a string.
So I did a thing:
<script type="text/javascript">
// Wait for the page to load first
window.onload = function() {
//Get a reference to the link on the page
// with an id of "mylink"
var a = document.getElementById("mylink");
//Set code to run when the link is clicked
// by assigning a function to "onclick"
a.onclick = function() {
var endDate = new Date("2019-05-10");
var curDate = new Date();
if (endDate > curDate)
{
window.location.replace('/AppName/page/page');
} else {
return "";
}
}
</script>
...and html element for the onclick function:
<body>
<p>This is a clickable <span id="mylink">thing right here!</span></p>
</body>