You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
Required fields*
-
@Amy Because that's describing pass by value, not pass by reference. This answer is a good one that shows the difference: stackoverflow.com/a/3638034/3307720nasch– nasch2019年03月27日 17:03:19 +00:00Commented Mar 27, 2019 at 17:03
-
@nasch I understand the difference. #1 and #2 are describing pass-by-ref semantics. #3 is describing pass-by-value semantics.user47589– user475892019年03月27日 17:32:42 +00:00Commented Mar 27, 2019 at 17:32
-
@Amy 1, 2, and 3 are all consistent with pass by value. To have pass by reference you would also need 4: assigning the reference to a new value inside the function (with the = operator) also reassigns the reference outside the function. This is not the case with Javascript, making it exclusively pass by value. When passing an object, you pass a pointer to the object, and you pass that pointer by value.nasch– nasch2019年03月27日 17:35:42 +00:00Commented Mar 27, 2019 at 17:35
-
That isn't generally what is meant by "pass-by-reference". You've satisfied my query, and I disagree with you. Thanks.user47589– user475892019年03月27日 17:38:52 +00:00Commented Mar 27, 2019 at 17:38
-
"In my book that's called passing by reference." – In every single compiler book, interpreter book, programming language theory book, and computer science book ever written, it is not.Jörg W Mittag– Jörg W Mittag2020年06月01日 10:53:11 +00:00Commented Jun 1, 2020 at 10:53
lang-js