Copy a string: Difference between revisions

Content deleted Content added
→‎{{header|Perl}}: lexical alias
→‎{{header|JavaScript}}: passing strings by reference
Line 301:
<lang javascript>var src = "Hello";
var dst = '' + src;</lang>
 
Note that <code><nowiki>'' + src</nowiki></code> concatenation was used to make sure that the string is actually copied instead of being passed by reference, but since strings in JavaScript are immutable and always compared by value, there is no way to test whether any two given variables are both references to the same string or two distinct strings which just happen to have the same value. So in practice this code is exactly equivalent:
<lang javascript>var src = "Hello";
var dst = src;</lang>
even though the string might or might not have been actually copied.
 
=={{header|Joy}}==