You can not. Javascript always jumps by value. And all this is an object; var stores a pointer, so it passes the value of the pointer.
If your name = "bar" must be inside the function, you will need to pass the entire array. Then the function will have to change it using array["reference"] = "bar" .
Btw, [] is an array literal. {} is an object literal. This array["reference"] works because the array is also an object, but the array must access the index based on 0. You probably want to use {} .
And foo["bar"] equivalent to foo.bar . A longer syntax is more useful if the key can be dynamic, for example, foo[bar] , and not quite with foo.bar (or if you want to use a minimizer such as the Google Closure Compiler).
source share