2
In PHP it is possible to pass variables by reference when we flag the parameter name with a &
before. And thus, the variable can be changed without the need to reallocate value.
Example:
function fn(&$x) {
$x *= 5;
}
$y = 2;
fn($y);
echo $y; // Imprime 10
What about javascript? Is there any way to do something like this?