You cannot pass a value by reference in JS. You can create an object with a function that will do this for you:
function TryAppend(originalValue) {
this.Value = originalValue;
this.Append = function (append) {
this.Value+=append;
return true;
}
}
Then you can use this in any method as follows:
function AnyProcedure() {
var str = "Checking";
var append = new TryAppend(str);
if (append.Append("TextBox")) {
alert(append.Value);
}
}
Each time you call append, it is added to the value string. I.e.
If you have done this:
append.Append(" Foo");
append.Value will be equal to CheckingTextBox Foo.
source
share