我有下面的代码部分:为什么不工作条件?
var SocketChat = socketFactory({
ioSocket: (typeof io === 'undefined') ? io.connect('http://test.com:8181') : null
});
我尝试检查是否存在io
对象为:
(typeof io === 'undefined')
,但我得到的错误ReferenceError: io is not defined
仍然
读[这](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Conditional_Operator) – Lucius