get the date for the last day of the current year in javascript

You can get the last day of the current year in JavaScript using the Date object. Here's the code:

index.tsx
var year = new Date().getFullYear(); // get current year
var lastDay = new Date(year, 11, 31); // set the date to December 31st of the current year
148 chars
3 lines

In this code, getFullYear() returns the current year, 11 represents December (since months are 0-indexed in JavaScript), and 31 represents the last day of December. This creates a new date object that is set to the last day of the current year.

gistlibby LogSnag