From 7707aaa9fe7c0996055385bdf76ec5af7cdd4677 Mon Sep 17 00:00:00 2001 From: paroche <46547072+paroche@users.noreply.github.com> Date: Fri, 27 Sep 2019 19:37:57 -0600 Subject: [PATCH] Update solution.md Replace 'this' in 'apply' call with empty object. Figured it was easier to bring up issue w/ PR than as a discussion. This would be just for clarity, since, as far as I can tell, 'this' will always be 'undefined' in the returned function, but having it there anyway could make one wonder if if might actually have a useful value (if the new Function prototype was used with an object method). From what I've been able to discern, it would not -- it would always be 'undefined' (in strict mode, of course). Same example I was wrong about before -- am I wrong again? And, if I'm not, IS there a way to make the prototype wrapper work with an object method that uses 'this'? --- .../2-defer-to-prototype-extended/solution.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/08-prototypes/03-native-prototypes/2-defer-to-prototype-extended/solution.md b/1-js/08-prototypes/03-native-prototypes/2-defer-to-prototype-extended/solution.md index e3651683fa..8fc0c9f13e 100644 --- a/1-js/08-prototypes/03-native-prototypes/2-defer-to-prototype-extended/solution.md +++ b/1-js/08-prototypes/03-native-prototypes/2-defer-to-prototype-extended/solution.md @@ -4,7 +4,7 @@ Function.prototype.defer = function(ms) { let f = this; return function(...args) { - setTimeout(() => f.apply(this, args), ms); + setTimeout(() => f.apply({}, args), ms); } };