Want to display last day of the previous month using JS.
I need pure JS code than other Library.
Format Needed : Jan 31, 2017
Want to display last day of the previous month using JS.
I need pure JS code than other Library.
Format Needed : Jan 31, 2017
 
    
    I always use Moment.js whenever I want work with dates which gives you lot's of options for format your date, but since you said with plain javascript, you can made a method like this to format your date :
function formatDate(date) {
   date.setDate(0);
   var monthNames = [
    "January", "February", "March",
    "April", "May", "June", "July",
    "August", "September", "October",
    "November", "December"
 ];
 var day = date.getDate();
 var monthIndex = date.getMonth();
 var year = date.getFullYear();
 return  monthNames[monthIndex] +  ' ' + day  + ' ' + year;
}
console.log(formatDate(new Date())); 
Basiclly date.setDate(0); will change the date to  last day of the previous month.
