0

Please can someone confirm the following assertions about the code below?

  • the contents (i.e. the string it is pointing to) of str will not be copied when it is passed as an argument into f
  • that parameter p, created in the execution context instantiated for the call to f is a value which is a reference to the memory containing the interned value "foo" (hence no copy occurred)
  • that String#slice does not copy p

    var str = 'foo';
    function f(p) {
      return p.slice(2); // creates a new string with "o" as the contents
    }
    f(str);
    
Ben Aston
  • 53,718
  • 65
  • 205
  • 331

1 Answers1

0

I confirm.

P.S.: is it really all you needed?

Community
  • 1
  • 1
Mycolaos
  • 74
  • 1
  • 5
  • you should provide some details on why you confirm this, including references, examples and/or explanations – thedude Apr 27 '17 at 09:53