[latex]Mae govannen![/latex]
function isObject(o) {
return (typeof o === 'object' && !(o instanceof Array) && o !== null);
}
function isArray(a) {
return (typeof a === 'object' && a instanceof Array);
}
>
> Warum ist das `typeof a` in `isArray()` notwendig?
Nicht. Kommt, weil ich die Objekt-Funktion "ge-c&p't" habe und nur den hinteren Bereich angepasst habe :(
> Meiner Meinung nach könnte man auch `typeof o === 'object' && o !== null` zu `o instanceof Object` zusammenfassen.
Prinzipiell schon, aber:
~~~javascript
var c = {
a: 2,
b: 3
}
function T1() {
this.a = 4;
}
b = new T1()
alert( c instanceof Object)
alert( b instanceof Object)
alert( window instanceof Object)
alert(isObject(c))
alert(isObject(b))
alert(isObject(window))
~~~ ergibt im IE6 true true false true true true , im FF/Opera 6 \* true
Cü,
Kai
--
Ash nazg durbatulûk, ash nazg gimbatul,ash nazg thrakatulûk, agh burzum-ishi krimpatul
selfcode sh:( fo:| ch:? rl:( br:< n4:# ie:{ mo:| va:) js:) de:> zu:) fl:( ss:| ls:?