How can I pass a string value by reference in javascript.
I want this kind of functionality.
//Library.js
function TryAppend(strMain,value)
{
strMain=strMain+value;
return true;
}
//pager.aspx
function validate()
{
str="Checking";
TryAppend(str,"TextBox");
alert(str); //expected result "Checking" TextBox
//result being obtained "Checking"
}
How to do this. ?
You cannot pass a value by reference in JS. You could create an object with a function to do this for you:
You can then use this in any method as follows:
Each time you call append, the Value string will be appended to. I.e.
If you then did:
append.Valuewould equal CheckingTextBox Foo.