1 min read

2 Fun JS Curiosities

2 Fun JS Curiosities
Photo by Hassaan Here / Unsplash

Did you know that in JavaScript, you can directly access a DOM element by its id without using document.getElementById()?

While this might seem like a shortcut, I don't recommend using it. It's not very readable and can lead to confusion, especially in larger projects or when working with multiple developers.


Did you know there's a native way to optimize DOM repaints? DocumentFragment comes to the rescue!

This is an in-memory DOM container with no visual representation. It allows you to batch DOM updates by moving its contents to the document in a single operation, reducing reflows and improving performance. Very interesting when you need to make complex DOM operations 😉