new Date().getFullYear() method. This will return the four digit year in a
new Date() method gets today's date:
var todaysDate = new Date() // 2019-12-03T07:11:20.082Z
todaysDate variable will have a value similar to the one shown above.
Using that variable, we can get the current year:
var todaysDate = new Date() var currentYear = todaysDate.getFullYear() // 2019
As shown above, the currentYear will hold the value for the current year.
You can also combine the two variables shown above to be more succinct:
var currentYear = new Date().getFullYear() // 2019
Thanks for reading and happy coding!