Web APIs (navigator, geolocation, history)

What advantage does this Permissions API approach offer over directly calling geolocation methods?
navigator.permissions.query({name: 'geolocation'}).then(result => {
  if (result.state === 'granted') {
    startTracking();
  } else if (result.state === 'prompt') {
    showLocationBenefits();
  } else if (result.state === 'denied') {
    showEnableLocationInstructions();
  }
  
  result.addEventListener('change', () => {
    // Handle permission changes
    console.log('Geolocation permission state:', result.state);
  });
});
Next Question (10/40)