测试ClojureScript中是否存在某种东西的方法是什么?例如,我正在尝试访问浏览器地理定位API。在javascript中,我会这样做一个简单的检查:
// 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.');
}
但是把它翻译成C
我正在尝试在clojurescript中实现以下javascript代码: const a = {
"foo": "bar",
//...
};
let b = {
...a,
//^ what is the clojurescript equivalent for this?
"newprop": 10,
}; 我尝试过assoc-in,认为它会表现得像一个clojure map,但没有成功……
我想知道是否有一种方法可以让ClojureScript析构处理JavaScript对象,例如:
(let [{:keys [a b]} #js{:a 10, :b 20}]
(print a) ;=> I get nil, but I'd want to get 10
(print b)) ;=> I get nil, bu I'd want to get 20
谢谢