When should you use querySelector and when should you use getElementById?
They answer different questions, and they are not interchangeable. getElementById takes an exact element id and gives you that one element or null. querySelector takes a full CSS selector, so it can match by tag, by class, by attribute, or by any combination, and it gives you the first match in document order.
For a plain id lookup, getElementById is the right tool. It is a direct lookup rather than a selector match, so it is faster and it never throws an error. If the id does not exist, you get null.
For everything else, querySelector is the better tool. It says what you want in one short string, and the selector syntax lets you do things that have no equivalent with getElementById, such as finding the first element with a given class, or the first list item inside a particular list.
There is one classic mistake to warn about. The older getElementsByClassName and getElementsByTagName methods return a live collection, which updates itself as the page changes. It is not a real array, it has no forEach method, and iterating it while you change the page can produce surprising results. The querySelectorAll method returns a static array instead, and that is almost always what you want.
Two more notes for an interview. The getElementById method only works with an id attribute, and putting the same id on two elements is invalid markup even though the method would give you the first one. And when you need many elements, querySelectorAll is the answer, because it gives you an array that you can loop over with forEach or map.