-4

I just want to pass the value from my new1 and new new2 function to new3 function, where new1 and new2 containing object..

function new1(obj1){ 
  var a = obj1.x;
}

function new2(obj2){
  var c=obj2.y;
} 

function new3(){
  if(a<c){
    dosomething();
  }
}
user2767633
  • 17
  • 1
  • 1
  • 5

1 Answers1

1

You already have access to the properties in question since they must be passed to the first two functions. There is no need to operate on the private a and c variables.

function new1(obj1){ 
  var a = obj1.x;
}

function new2(obj2){
  var c=obj2.y;
} 

function new3(obj1,obj2){
  if(obj1.x < obj2.y){
    dosomething();
  }
}

new1(obj1);
new2(obj2);
new3(obj1,obj2);
TGH
  • 37,937
  • 11
  • 96
  • 131