JavaScript querySelector method is used to select elements from the DOM (from the webpage). It returns the 1st match element.
querySelector uses CSS selector like p, h1, .class1, .class1 > span, #id1, etc to select the element from the DOM.
If the targeted element exists in the DOM, it will return the 1st match from the DOM, if not it will return null.