Bab 7: Browser APIs dan Web APIs
Bab 7: Browser APIs dan Web APIs
7.1 Local Storage dan Session Storage
7.1.1 Local Storage
// Storing data
localStorage.setItem('user', JSON.stringify({
name: 'John',
age: 30
}));
// Retrieving data
const user = JSON.parse(localStorage.getItem('user'));
// Removing specific item
localStorage.removeItem('user');
// Clearing all data
localStorage.clear();
// Storage event
window.addEventListener('storage', (e) => {
console.log('Storage changed:', {
key: e.key,
oldValue: e.oldValue,
newValue: e.newValue,
url: e.url
});
});7.1.2 Session Storage
7.2 Cookies
7.2.1 Cookie Management
7.3 Geolocation API
7.3.1 Getting Location
7.4 Web Workers
7.4.1 Basic Web Worker
7.4.2 Shared Workers
7.5 Service Workers
7.5.1 Service Worker Registration
7.6 Canvas API
7.6.1 Basic Canvas Operations
7.7 WebSocket
7.7.1 WebSocket Connection
7.8 Web Audio API
7.8.1 Audio Manipulation
7.9 Praktik dan Latihan
7.9.1 Project: Offline-Capable Web App
7.10 Best Practices
7.11 Ringkasan
7.12 Latihan Akhir Bab
Last updated