What is the way to test if something exists in ClojureScript ? For instance, I am trying to access the browser geolocation API. In javascript, I would do a simple check like that :
// check for Geolocation support
if (navigator.geolocation) {
console.log('Geolocation is supported!');
}
else {
console.log('Geolocation is not supported for this Browser/OS version yet.');
}
But translating it to ClojureScript, I get an error :
(if (js/navigator.geolocation) ;; Uncaught TypeError: navigator.geolocation is not a function
(println "Geolocation is supported")
(println "Geolocation is not supported"))
What is the proper way to check browser capabilities in ClojureScript ?