A function modifyTestessentially creates a local function level variable called s; this variable exists only within the framework of the function; therefore, its change will not affect the external volume.
, :
var test = "This is a simple test";
function modifyTest(){
test = "modified test text";
}
console.log(test);
modifyTest();
console.log(test);
, , - :
var o = { test: 'This is a simple test' };
function modifyTest(x){
x.test = 'modified test text';
}
modifyTest(o);
console.log(o.test);
, :
var o = { test: 'This is a simple test' };
function modifyTest(x, name){
x[name] = 'modified test text';
}
modifyTest(o, 'test');
console.log(o.test);