var myMegaObject function var function log console log log1 return fun

 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
29
30
31
32
33
34
35
36
37
38
39
40
var myMegaObject = (function(w){
var a, b, c;
function log(a){
console.log('log1', a)
}
return function(b){
this.b = b;
this.getb = function(){
log( this.b );
}
}
})(window);
myMegaObject.add = function(){}
myMegaObject.prototype = (function(){
var x,y,z;
function log(a){
console.log('log2', a)
}
return {
c: 1,
getc: function(){
log(this.c)
},
event: function(fn){
var c = this.c
this.c.onclick = function(){
if(fn.call(c) == false)
return false;
}
}
}
})();
var myObj = new myMegaObject('asd')
myObj.event(function(){
alert(1)
});