Ok, long story short, i have 2 classes(functions) and need extend one from second.. In the end of hard day, i wrote simply solution, but then i come home, i thought this is wrong.. But.. Actually it's working, only i don't understand why.. So for example i have 2 functions:
function aa() {
  var r = "aaaa";
  this.method = function(){
    console.log(r);
  }
}
function bb() {
  var e = "bbbb";
  this.method2 = function(){
    console.log(e);
  }
}
var a = new aa();
var b = new bb();
After i use this function to merge them:
var merge = function(one, two) {
  for(var method in two) {
    one[method] = two[method];
  }
  return one;
}
var c = merge(a, b);
And this is work fine.. so question is why? I guess in 'merge' function, i just add to first object method of second, but this method used private variable what not defined in first object, why he sees it?
 
     
     
     
     
    