compare string with today's date in JavaScript

    <script type="text/javascript">

var q = new Date();
var m = q.getMonth()+1;
var d = q.getDay();
var y = q.getFullYear();

var date = new Date(y,m,d);

mydate=new Date('2011-04-11');
console.log(date);
console.log(mydate)

if(date>mydate)
{
    alert("greater");
}
else
{
    alert("smaller")
}


</script>

Exact date comparsion and resolved bug from accepted answer

var q = new Date();
var m = q.getMonth();
var d = q.getDay();
var y = q.getFullYear();

var date = new Date(y,m,d);

mydate=new Date('2011-04-11');
console.log(date);
console.log(mydate)

if(date>mydate)
{
    alert("greater");
}
else
{
    alert("smaller")
}

You can use a simple comparison operator to see if a date is greater than another:

var today = new Date();
var jun3 = new Date("2016-06-03 0:00:00");

if(today > jun3){
    // True if today is on or after June 3rd 2016
}else{
    // Today is before June 3rd
}

The reason why I added 0:00:00 to the second variable is because without it, it'll compare to UTC (Greenwich) time, which may give you undesired results. If you set the time to 0, then it'll compare to the user's local midnight.