script function Foo attr this mult function factor return attr factor

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
<script>
function Foo() {
attr = 4;
this.mult = function(factor) {
return attr * factor;
}
}
function test(method) {
return method(3);
}
foo = new Foo()
console.log(test(foo.mult));
</script>