typeof ... undefined from JavaScript 的 ClojureScript 类似物是什么?
What is the ClojureScript analogue of typeof ... undefined from JavaScript?
我看到很多代码都在使用以下模式:
if (typeof a.b === 'undefined') { ...
现在我将其翻译成:
(if (nil? (-.b a)) ...
这合适吗?还是我丢失了一些重要数据?
我的问题是:JavaScript 中 typeof ... undefined
的 ClojureScript 模拟是什么?
要检查可能的 undefined
引用,您可以使用 cljs.core/exists?
:
(when-not (exists? js/unknownReference)
...)
我看到很多代码都在使用以下模式:
if (typeof a.b === 'undefined') { ...
现在我将其翻译成:
(if (nil? (-.b a)) ...
这合适吗?还是我丢失了一些重要数据?
我的问题是:JavaScript 中 typeof ... undefined
的 ClojureScript 模拟是什么?
要检查可能的 undefined
引用,您可以使用 cljs.core/exists?
:
(when-not (exists? js/unknownReference)
...)