Re:Deep-copying in JavaScript
by rising-sky on Thursday January 25, 2018 @03:34PM
(#16234379)
You are correct, but it would so help to explain to the reader what the correct evaluation strategy employed by JavaScript is: call-by-sharing.
https://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_sh...
[ Parent
| on HN ]
Not quite accurate. The primitive types (string, number, null, boolean, symbol, undefined) are passed only by value. Also, the page you link to says "the terminology is inconsistent across different sources", so it doesn't seem an ideal choice. Javascript is pass by value, with some of those values being references.
Would you know that some Javascript engines store primitives on the heap, so potentially it can all be described as call-by-sharing? Then again, they are immutable, so it is indistinguishable from call-by-value.
I think making these distinctions is somewhat asinine and that it doesn't really do more than make people aware that the function call interface actually has some interesting design considerations. It's sort of like "ok, we have decided whether a hamburger is a sandwich. Now we can finally do the thing that desperately depended on this decision, which was, uhh..."