Copyright Up To Date (The Automate Way)

Web Developer | React.js | JavaScript | Check out my blog: https://blog.eligarlo.dev
Search for a command to run...

Web Developer | React.js | JavaScript | Check out my blog: https://blog.eligarlo.dev
Thank you Ankur! 🙏
React is a popular JavaScript library that provides developers with a powerful and efficient way to build user interfaces. One of the key features of React is the ability to use a method called createPortal to render components outside the main conte...

For a good work-life balance, stay active and healthy.

A few days ago I decided it was time for me to update myself to the new version of Vuejs, Vue 3. And today I wanted to share with you the first thing I learn that version two didn't have, the teleport component. It's well known that modern web applic...

Definition of trim, "To cut away unnecessary parts from something." - Oxford Dictionary. Sometimes, validating forms in JavaScript can be a tedious task for a developer. You have to check many things. For instance, that the values given are of the t...

We always have to validate if the arguments passed in a function have a value or they are undefined but, do we really? Introduction In my last post, I talked about Destructuring Assignment In A Function Parameter and why it is handy when you have opt...

Let's be honest, outdated copyright disclaimers on a website looks bad. Looks like the website it's unmaintained on many levels. On the other hand, you don't want to manually update it every 1st of January on every website you own right? Let me help you automate this task with 2 lines of code. If you want to know more about the importance of updating your copyright dates I found this post with a more in-depth explanation.
First, let's create a basic HTML template where we will have our copyright disclaimer at the footer:
<body>
<header>Lorem ipsum dolor sit</header>
<main>Lorem ipsum dolor sit amet consectetur adipisicing elit.</main>
<footer>Copyright © <span id="copyright"></span>, My Company Name</footer>
<script src="app.js"></script>
</body>
And then, our javascript will look like this:
const copyright = document.querySelector('#copyright')
copyright.innerHTML = new Date().getFullYear()
That's it, you are cover now. 😎
Bonus tip:💡
In case you need a range of years instead of a single year in your copyright disclaimer, you can easily tweak the above code.
<footer>Copyright © <span id="copyright">2010 - </span>, My Company Name</footer>
const copyright = document.querySelector('#copyright')
copyright.innerHTML += new Date().getFullYear()
Thank you for reading, if you like my content, you can always find me on Twitter @eligarlo.