Salut,

Je continue mon exploration de la programmation orientée objet en Javascript. J'ai un problème sur la portée d'une variable (comme il est dit dans le titre). Voici de quoi illustrer mes propos :
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
21
22
23
24
25
26
27
28
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>test js</title>
</head>
<body>
    <script type="text/javascript">
	function o1() {
		this.f1 = function() {
			return "f1";
		}
	}
	function o2(a) {
		o1.call(this, a)
		function f3() {
			return this.f1;
		}
		this.f4 = function() {
			f3();
		}
	}
	o2.prototype = new o1;
 
	var t1 = new o2();
	alert(t1.f4(this));
    </script>
</body>
</html>
Comment récupérer f1 dans le scope de f3, si j'ai bien compris les termes?

Merci par avance.