简体   繁体   English

什么是类型的ClojureScript模拟...来自JavaScript的未定义?

[英]What is the ClojureScript analogue of typeof … undefined from JavaScript?

I'm seeing lots of code using the pattern: 我看到很多使用该模式的代码:

if (typeof a.b === 'undefined') { ...

Now I'm translating this to: 现在我将其翻译成:

(if (nil? (-.b a)) ...

Is that appropriate - or am I losing some crucial data? 这是合适的 - 还是我丢失了一些关键数据?

My question is: What is the ClojureScript analogue of typeof ... undefined from JavaScript? 我的问题是: 什么是类型的ClojureScript模拟typeof ... undefined来自JavaScript的typeof ... undefined

For checking for possibly undefined references you can use cljs.core/exists? 要检查可能undefined引用,可以使用cljs.core/exists? :

(when-not (exists? js/unknownReference)
  ...)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM