js function to get current year code example Example: Javascript get current year var currentYear= new Date().getFullYear();