How to print current year in JavaScript for copyright footer on websites

Problem: How to dynamically print the current year on the copyright footer of websites?

It is an hassle to manually update the copyright footer of websites every year to print the current year. For example © 2001 - Current Year

Solution: Use the following JavaScript to print the current year instead of hardcoding the year.

<script>document.write(new Date().getFullYear())</script>