【发布时间】:2014-06-10 10:24:25
【问题描述】:
我知道 (a instanceof Array) 但我将如何测试对象?
var c = {};
if ( c instanceof XXXX) {
// should get thru
}
var s = "abscdef";
if ( s instanceof XXXX) {
// should not get thru
}
var a = [];
if ( a instanceof XXXX) {
// should not get thru
}
【问题讨论】:
-
你到底是什么意思? {} 是一个对象,而不是一个集合。
-
您的术语很混乱 - c 是
Object,而不是“集合”。 -
好的,那么抱歉。那么如何检测任何类型的对象呢? (我编辑问题)
-
与数组相同。 if (c instanceof Object) ...
-
@Pilot 是关于 javascript 的,所以我会拒绝。