Create a new Date() object and call getFullYear() :

new Date().getFullYear()
// returns the current year

Hijacking the accepted answer to provide some basic example context like a footer that always shows the current year:

<footer>
    &copy; <span id="year"></span>
</footer>

Somewhere else executed after the HTML above has been loaded:

<script>
    document.getElementById("year").innerHTML = new Date().getFullYear();
</script>



document.getElementById("year").innerHTML = new Date().getFullYear();

footer {
  text-align: center;
  font-family: sans-serif;
}

<footer>
    &copy; <span id="year">2018</span> by FooBar
</footer>