Skip to content

Spy Decorator task solution -- args vs arguments #1294

@paroche

Description

@paroche

It currently reads:

Here we can use calls.push(args) to store all arguments in the log and f.apply(this, args) to forward the call.

function spy(func) {

function wrapper(...args) {
wrapper.calls.push(args);
return func.apply(this, arguments);
}

wrapper.calls = [];

return wrapper;
}

Even though the function works either way, seems like it might be clearer to just have "(this, args)" rather than "(this, arguments)" in the code. Unless the point is to remind us, en passant, that the "arguments" object exists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions