We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b2cedf7 commit ade541bCopy full SHA for ade541b
1-js/06-advanced-functions/09-call-apply-decorators/01-spy-decorator/_js.view/solution.js
@@ -1,11 +1,12 @@
1
function spy(func) {
2
3
function wrapper(...args) {
4
+ // using ...args instead of arguments to store "real" array in wrapper.calls
5
wrapper.calls.push(args);
- return func.apply(this, arguments);
6
+ return func.apply(this, args);
7
}
8
9
wrapper.calls = [];
10
11
return wrapper;
-}
12
+}
1-js/06-advanced-functions/09-call-apply-decorators/01-spy-decorator/solution.md
@@ -1 +1 @@
-Here we can use `calls.push(args)` to store all arguments in the log and `f.apply(this, args)` to forward the call.
+The wrapper returned by `spy(f)` should store all arguments and then use `f.apply` to forward the call.
0 commit comments