Avatar ·

How to get the current year in JavaScript?

Hi everyone! I just started learning JavaScript and ran into a problem. I need to display a copyright with the current year on my site so it automatically updates each year. I know there's a Date object, but I can't figure out how to properly extract just the year. Here's what I tried: ```javascript let date = new Date(); let year = date.getYear(); console.log(year); // Outputs something strange: 124 ``` Why am I getting 124 instead of 2024? I expected to see the current year. Maybe I'm using the wrong function? I saw online that some people use getFullYear(), but I'm not sure what the difference is. Please tell me how to correctly get the current year in JavaScript to use it in the site footer? And also explain why getYear() behaves so strangely.