Bonjour à tous... Voici le script qui essaye l'opérateur instanceof :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function A() {
	this.x = 0;
	this.y = '222';
	this.objDate = new Date();
	this.objB = new B();
}
function B() {
	this.bb = 99;
}
function dumpObj( obj )
{
	alert( "dans la fct obj == objet ? " + (obj instanceof Object) );
	for ( att in obj ) alert( att + " == objet ? " + (att instanceof Object) )
}
function testJSDebug()
{
	var obj = new A();
	alert( "avant appel obj == objet ? " + (obj instanceof Object) );
	dumpObj( obj );
}
En sortie :
avant appel obj == objet ? true
dans la fct obj == objet ? true
x == objet ? false
y == objet ? false
objDate == objet ? false
objB == objet ? false
En somme, il reconnait l'objet quand on le lui passe tel quel, mais pas quand il est pris comme attribut ??????
Ou bien (plus probablement...) j'ai raté un éléphant ?