I think (but am not sure) that Javascript actually pursues a call-by-sharing strategy for reference types (aka object types). With call-by-reference the callee should be able to reassign the caller's variable, right? Here is an example:
With call-by-ref xs should be [1], because the actual reference of the variable is passed. So what passes call-by-sharing then? Frankly, I don't know. I read somewhere it would only pass a copy of the reference. This doesn't make much sense to me though. A copy of a pointer to memory?
Anyway, this is just nitpicking. Essentially Javascript uses call-by-ref.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I think (but am not sure) that Javascript actually pursues a call-by-sharing strategy for reference types (aka object types). With call-by-reference the callee should be able to reassign the caller's variable, right? Here is an example:
With call-by-ref
xs
should be[1]
, because the actual reference of the variable is passed. So what passes call-by-sharing then? Frankly, I don't know. I read somewhere it would only pass a copy of the reference. This doesn't make much sense to me though. A copy of a pointer to memory?Anyway, this is just nitpicking. Essentially Javascript uses call-by-ref.