0

let's say we have variable a = "value1" and I pass it to a function through an argument called "arg" now inside the function, I'm assigning arg to a value "value2"

my question is : how passing arguments really work? will "value2" be assigned to "arg" or variable "a" or both? does arg get replaced with variable a (during passing)? and what really confuses me is what gets passed, is it the name of the variable or its value ? thank's

    var a = "value1";

    function myfunc(arg) {        
        arg="value2";
    }

    myfunc(a);
  • Possible duplicate of [Is Java "pass-by-reference" or "pass-by-value"?](https://stackoverflow.com/questions/40480/is-java-pass-by-reference-or-pass-by-value) – Joooeey Oct 10 '18 at 00:51
  • 2
    The question asks about JavaScript though, not Java. – Nick Cox Oct 10 '18 at 00:53
  • 1
    Perhaps he meant to link to [this question](https://stackoverflow.com/questions/518000/is-javascript-a-pass-by-reference-or-pass-by-value-language) instead. – CRice Oct 10 '18 at 01:02

0 Answers0