I am. A beginner of JavaScript and am confused that what is the difference between document.querySelector('#button') and document.getElementById('button')?
For example,
function myFunction() {
  document.querySelector("#demo").innerHTML = "Hello World!";
}
And
function myFunction() {
  document.getElementById("demo").innerHTML = "Hello World!";
}
Give the same result. Then what is the difference between them?
I know that querySelector() returns the first element matching, but IDs are already unique...
 
     
    