I have two modules and in the first one I declare an object because I know that primitives are passed by value in java script and objects by reference.I want to get the response status from a request and I am passing the object as a reference so I will be able to modify its property.The problem is that it doesn't do anything.In the end the value would be the same.
//this code is in a different module from the other one
var variableToBeChanged = { something : "Initial value" };
anotherModule.changeValue(variableToBeChanged);
alert(variableToBeChanged.something);
//and in the other module I have a $.ajax and I want to get the response status(ex. 200)
//the code is sth like this:
function AnotherModule(ajax){
  function changeValue(variableToBeChanged){
    ...
    ...
    ...
    $.ajax({
      ...
      ...
      ...
      success: function(data,xhr){
          variableTobechanged.something = xhr.status;
      }
    });
  }
}In the end it will display: "Initial value" instead of 200 or anything else. What am I doing wrong here?
 
     
    