Is there any way to create\return a pointer to variable in JavaScript ?
like, in PHP :
function func() {
.....
return &$result;
}
I have a JS function like:
function(...) {
x=document.getElements..... //x is HTML tag
if (x.localName=='input') return x.value //String variable
else if (x.localName=='textarea') return x.innerHTML //String variable
}
Using this function, I can get a copy of the data from x, but not to change the source.
I want possibility to change it too.
Thanks
No, you can't return a pointer to a string. In Javascript Objects are assigned and passed by reference automatically, and primitives are copied. So if you return x; then you can modify x.innerHTML, but if you return x.innerHTML the string will be copied.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With