DOM Querying Concept
Concept Check Easy
Question
What does document.querySelector('.btn') return if no element matches?
Hint
Think about what 'no match' means for a single-element query.
Explanation
querySelector returns the first matching element, or null if no element matches the selector. It does not throw an error or return undefined. querySelectorAll returns a NodeList (empty if no matches). Always check for null before using the result.
Related Resources
Related Lessons
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.