I want to write a generic way to change properties inside a function. It actually happens inside a function, but I think the problem can be simplified in the following way.
var showItemA = true;
var showItemB = true;
var showItemC = false;
var switchToggle = function (toggleTarget) {
toggleTarget = !toggleTarget
// Do other stuff
console.log(toggleTarget);
//false
};
switchToggle(showItemA);
console.log(showItemA);
//true; but I want it to be false
I am well aware of this earlier question, but I need it to be generic to handle different properties. Is there a way to throw outside variables or properties at a function and have it change their value?