I am following a tutorial on browser detection which is using two !!
not operator in return. I want to know what is the significance of using 2 !! in a code.
function supports_geolocation() {
return !!navigator.geolocation;
}
I believe !!navigator.geolocation === navigator.geolocation
.
Correct me if not and let me know the significance of using two not operator here.
It force returns boolean value.
// navigator.geolocation is GeoLocation object
navigator.geolocation === true // return false
!!navigator.geolocation === true // returns true