Recently I develop some static pages and got few pages
Uncaught TypeError: Cannot read property 'innerHTML' of null or similar kind of issues.
<h2 class="">Hello World</h2> <script> let demo = document.querySelector('.demo') console.log(demo.innerHTML) </script>
but, if we make it short with just logical operators
&& it's not giving any TypeError. For example,
let demo = document.querySelector('.demo') demo&&( console.log(demo.innerHTML) )