You can't. When you do
reusableFunction(variable);
the value of variable is passed into the function, not the variable itself. The parameter passedVariable is not in any way connected to variable. That is, you end up with something like this in memory:
+−−−−−−−−−−−−−−−−−+
| variable: false |
+−−−−−−−−−−−−−−−−−+
+−−−−−−−−−−−−−−−−−−−−−−−+
| passedVariable: false |
+−−−−−−−−−−−−−−−−−−−−−−−+
You could pass in an object and have the function update a property on it instead:
let obj = {
prop: true
};
let reusablefunction = (passedObject) => {
setTimeout(() => {
passedObject.prop = false;
}, 1); // No need to pass the parameter here
};
reusablefunction(obj);
With that, you end up with something like this in memory:
+−−−−−−−−−−−−−−−+
| obj: Ref55461 |−−−−−−−−−−−−−+
+−−−−−−−−−−−−−−−+ |
| +−−−−−−−−−−−−−+
+−−−−−−−−−>| Object |
| +−−−−−−−−−−−−−+
+−−−−−−−−−−−−−−−−−−−−−−−−+ | | prop: false |
| passedObject: Ref55461 |−−−−+ +−−−−−−−−−−−−−+
+−−−−−−−−−−−−−−−−−−−−−−−−+
Since both obj and passedObject refer to the same object, you can change its properties via either of them.
That said, there may well be a better way to solve the underlying problem you're trying to solve...