Useful Browser APIs — Concept Check
Questions on Useful Browser APIs. Clipboard, geolocation, notifications, media queries, crypto and Web Workers — the built-ins worth knowing before reaching for a library.
Questions in this quiz
8 questions on Useful Browser APIs — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.A user clicks a button to copy text to the clipboard, but nothing happens. What might be the issue?
- AThe clipboard API does not require user interaction.
- BThe clipboard API can only be used on page load.
- CThe clipboard API is not supported in any browser.
- DThe clipboard API requires a secure context.
2.You want to generate a random UUID for a session ID in your web app. Which method should you use?
- AUUID.generate()
- Bnew UUID()
- CMath.random()
- Dcrypto.randomUUID()
3.A web application needs to detect if the user prefers a dark theme. Which approach is correct?
- AUse navigator.theme === 'dark'
- BRead from localStorage for theme preference
- CUse window.matchMedia('(prefers-color-scheme: dark)').matches
- DCheck document.body.style.backgroundColor
4.A developer wants to request notification permissions as soon as the page loads. What is a likely consequence?
- AThe request will prompt the user immediately.
- BThe request will be blocked permanently.
- CThe request will succeed without user interaction.
- DNotifications will be granted automatically.
5.A web app uses a Web Worker for heavy computations but the UI still freezes. What could be the problem?
- AThe Web Worker is incorrectly implemented.
- BWeb Workers can access the DOM, causing delays.
- CThe main thread is still handling other blocking tasks.
- DWeb Workers do not support parallelism.
6.How can you check if the user has granted notification permissions without prompting them?
- AUse window.matchMedia('(notifications: granted)')
- BCall Notification.requestPermission()
- CUse navigator.permissions.query({ name: 'notifications' })
- DCheck navigator.notificationStatus
7.A developer uses crypto.getRandomValues() to generate random numbers for a game. Why is this a good choice?
- AIt provides cryptographically secure random numbers.
- BIt generates random numbers in a more readable format.
- CIt is the only method available in JavaScript.
- DIt is faster than Math.random().
8.A user denies geolocation access the first time. What should the application do next?
- AIgnore the denial and proceed as if granted.
- BKeep requesting access until granted.
- CHandle the denial and offer alternative functionality.
- DAssume the user will enable it in settings later.