Device Capabilities
Device Capabilities
Section titled “Device Capabilities”Introduction
Section titled “Introduction”The navigator object provides access to device features like cameras, storage, and network information.
Media Devices
Section titled “Media Devices”navigator.cookieEnabled; // Are cookies enabled?
// Access camera/microphonenavigator.mediaDevices.getUserMedia({ video: true, audio: true }) .then(stream => { videoElement.srcObject = stream; }) .catch(err => console.error('Camera access denied:', err));Storage and Connection
Section titled “Storage and Connection”// Storage estimatesconst storage = await navigator.storage.estimate();console.log('Used:', storage.usage, 'Quota:', storage.quota);
// Connection info (Chrome only)const connection = navigator.connection;if (connection) { console.log('Connection type:', connection.effectiveType); // '4g', '3g', etc. console.log('Round-trip time:', connection.rtt, 'ms');
connection.addEventListener('change', () => { console.log('Connection changed to:', connection.effectiveType); });}Summary
Section titled “Summary”navigator.mediaDevices.getUserMedia()— camera/microphone accessnavigator.storage.estimate()— storage quota informationnavigator.connection— network type and speed- Always handle permission denials gracefully