To get the current year in JavaScript, you can use the Date object. First, create a new Date instance, then call the getFullYear() method. This method returns the current year as a four-digit number. For example:
const currentYear = new Date().getFullYear();
console.log(currentYear); // Outputs the current year, e.g., 2025
This approach works across all modern browsers and is straightforward for retrieving the current year. You can use this value in applications requiring date-related functionality, such as displaying the year dynamically in a footer or calculating age.