Skip to content

Commit 08cbdaf

Browse files
authored
Merge pull request sadanandpai#23 from lapstjup/main
Fix bind and soft bind polyfill
2 parents e0e88f1 + 0a87512 commit 08cbdaf

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

challenges/functions-challenges.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ if(!Function.prototype.bind){
114114
var fnArgs = Array.prototype.slice.call(arguments, 1);
115115

116116
return function(){
117-
var allArgs = funcArgs.concat(Array.prototype.slice.call(arguments))
117+
var allArgs = fnArgs.concat(Array.prototype.slice.call(arguments))
118118
fn.apply(context, allArgs);
119119
};
120120
}
@@ -142,8 +142,8 @@ function softBind(fn, context) {
142142
var allArgs = fnArgs.concat(Array.prototype.slice.call(arguments));
143143

144144
// override the context to incoming context if it is not undefined, null or window
145-
var context = (!this || this === window) ? obj : this;
146-
fn.apply(context, allArgs);
145+
var finalContext = (!this || this === window) ? context : this;
146+
fn.apply(finalContext, allArgs);
147147
};
148148
}
149149
```
@@ -641,4 +641,4 @@ This is a well known JavaScript pattern called as __Publish/Subscribe Pattern__
641641
642642
<br />
643643
644-
[[↑] Back to top](#home)
644+
[[↑] Back to top](#home)

0 commit comments

Comments
 (0)