Lets say I have an inline script tag that has a very simple code as follows
(function() {
var test = "This is a simple test";
function modifyTest(s) {
s = "Modified test text";
};
modifyTest(test);
console.log(test) //Will still display "This is a simple test"
})();
However if i use test = modifyTest(test);
the change is applied my question is this.
Is this the only way to modify a variable in javascript inside a function, meaning i must always do
source = function(source);
inorder to alter a variable inside a function,
or am i missing a scope concept that is preventing me from accomplishing this?