Hi I have the following javascript code
var skyrimCity = function(object) {
object = {
'world': 'whiterun'
};
},
skyrim = function(object) {
object.world = 'skyrim';
},
elderScrolls = {
'world': 'tamriel'
};
console.log(elderScrolls); // printed value ? -> {world: "tamriel"}
skyrimCity(elderScrolls);
console.log(elderScrolls); // printed value ? -> {world: "tamriel"}
skyrim(elderScrolls);
console.log(elderScrolls); // printed value ? -> {world: "skyrim"}
Inside skyrim function I changed the value of world but I can see it outside the function as well. I am wondering why the scope of this change propagated outside the function? Is passing an object inside a javascript function always passed as a reference to the original object itself?