From 0805eb020248dfa8f6ea508e30d1f7f0211e8d79 Mon Sep 17 00:00:00 2001 From: sezgi Date: Wed, 9 Jun 2021 17:59:30 -0700 Subject: [PATCH] add lexical this, args, and return add arrow fn to get lexical this for brevity; args for e.g. boundFn(5); return value of original fn --- answers/bind-a.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/answers/bind-a.js b/answers/bind-a.js index 379c54a..6ace107 100644 --- a/answers/bind-a.js +++ b/answers/bind-a.js @@ -1,6 +1,5 @@ Function.prototype.bind = function(context) { - const _this = this; - return function() { - _this.apply(context); + return (...args) => { + return this.apply(context, args); } }