This is not what is passed by reference. Passing by reference will mean this:
var args = { hello: 'world' }; function myFunction(args) { args.hello = 'hello'; } myFunction(args); console.log(args);
And the above is impossible.
Variables contain only references to objects; they are not the object itself. Therefore, when you pass in a variable that is a reference to an object, that link will of course be copied. But the specified object is not copied.
var args = { hello: 'world' }; function myFunction(args){ args.newHello = 'another world'; } myFunction(args); console.log(args);
Yes, it is possible, and you can see it just by running the code.
Esailija
source share