Continuing @WebReflection's idea from the now-closed ES Discuss mailing list, pass by reference would be a way to accept parts of objects and be able to modify them:
soSomething({a: 123, b: 456})
where
function doSomething({&b}) {
b = 789 // we can only modify b (which modifies the b property of the user's passed-in object.
}
The above concept as @WebReflection described is currently similar to:
function doSomething(o) {
with (o) {
b = 789 // we can modify b (which modifies the b property of the user's passed-in object).
// but we can also modify `a`.
}
}
Andrea mentioned security. If it were to be secure, it would need to be opt-in on the consumer side that passes arguments, not just in the library side:
soSomething(o with b) // or some syntax
Then, if an attacker changes the function header from doSomething({&b})
to doSomething({&a})
there would be a runtime error because the user did not allow a
to be referenced.