Is there a way to detect whether a user has already given permission for geolocation

Is there a way to detect whether a user has already given permission to use navigator.geolocation?

I can use localStorage, but the problem is in case the user clears location setting from browser. In this case user still gets true from local storage even though location settings are cleared.

At this point in time the API doesn’t have that functionality, if you have a backend language such as PHP + MySQL then the other option would be to store the users choice within a database table but it really wouldn’t be worth the headache in my opinion.