Given the following code:
class ExampleClass {
someMethod(x) {
arguments[0] = 100;
console.log(arguments[0]);
return x;
}
}
let example = new ExampleClass();
console.log([example.someMethod("5")]);
function someFunction(x) {
arguments[0] = 100;
console.log(arguments[0]);
return x;
}
console.log([someFunction("5")]);
I would expect the output to be:
100
[100]
100
[100]
However in the class example this doesn't seem to work and instead it changes arguments[0]
to 100 like it should but x remains unchanged.
So instead the output is:
100
["5"]
100
[100]
Is there some kind of workaround or will arguments
never affect the parameters inside a class method?