🔹 Definition:
Web APIs are browser-provided interfaces that allow JavaScript to interact with the browser environment, device hardware, or web services.
They are not part of the JavaScript language itself, but built into modern browsers and accessible through JavaScript.
🔹 Common Examples of Web APIs:
- DOM API
Manipulate HTML and CSS
→document.querySelector(),document.getElementById() - Fetch API
Perform HTTP requests
→fetch('https://api.example.com/data') - LocalStorage / SessionStorage API
Store data in the browser
→localStorage.setItem('key', 'value') - Geolocation API
Get user’s location
→navigator.geolocation.getCurrentPosition() - Canvas API
Draw graphics on a canvas
→canvas.getContext("2d") - WebSockets API
Real-time communication
→new WebSocket('ws://example.com') - Notifications API
Show push notifications
→Notification.requestPermission()
🔹 Why Web APIs Matter:
- Extend JS functionality beyond the core language
- Enable richer, interactive web apps
- Provide access to powerful browser and system-level features