Okay so below is just making the navigation shrink on scroll but noticed something. It still worked even though I put nav.classList when it should of been mainNav.classList. I then logged in the console and nav and mainNav return samething even though nav isn't declared. It happens with every ID in my HTML so if I only type in the id name without getElementById it would still log out the node. I'm a little confused on why this works. Is this new to ES6?
var mainNav = document.getElementById('nav'); //The whole navigation
window.addEventListener('scroll', function(){
var scroll = window.pageYOffset | document.body.scrollTop;
if(scroll < 100){
nav.classList.remove('nav-shrink');
} else {
nav.classList.add('nav-shrink');
}
});