So here's a strange one:
var a = true;
function f(v){ v = !v; } //can this function actually change a?
f(a); //a is still true..
The function obviously changes only the value if it's internal v variable.
I came across this working on an application that should change the values of properties of DOM Elements dynamically at run time. So ideally there should be a function that takes a property as an argument and reassigns it, right?
for clarity - I am actually trying to assign new values to DOM element's attributes at runtime: I have a reflector application that iterates through members of objects and I want it to be able to change the value of properties that it comes across, so the f function would belong to a BooleanSwitch constructor function that builds a booleanSwitch object for every boolean type property in the reflected object. the booleanSwitch can be a simple button on screen. I want to be able to change the value of the actual property of the object at hand just by clicking the button.. can anyone think of a way to do this?
Any thoughts are appriciated..
returnstatement, or accept an Object argument?switch? This would not be a valid function name.ainside the function body, you're just assigning the variablevpassed as an argument.