2 ms·
Each approach is equally capable of resulting in an error state if unexpected input is supplied, for example pass an array into the document.getElementById. Th
by austincheney 7y ago
Each approach is equally capable of resulting in an error state if unexpected input is supplied, for example pass an array into the document.getElementById. The largest important difference is that the input to the querySelector must be parsed as a coded instruction, a selector, while the input to getElementById is a string literal that does not get parsed.