As we know, we can pass to function some arguments and then get access to them through arguments, like this:
function test() {
return arguments.length;
}
console.log(test('param1', 'param2', 'param3'));
But when the function is an object property, I collided with unexpected behavior for me: I can't get access to arguments inside this function. Here is an example:
const obj = {
test: () => {
if (arguments.length === 1) {
return true;
} else {
return false;
}
}
};
console.log(obj.test('param1'));
My question is: Why? And is there any other way to get access to passed parameters to this function? (notice, that my functions doesn't accept any arguments in both cases, but in first one I can read arguments, but in second I can't).