Skip to content

Commit e921ee4

Browse files
authored
question 21 rephrased
1 parent 06fbfb3 commit e921ee4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

challenges/functions.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
18. [Show the procedure of creating object using a factory function](#Q18)
2525
19. [Achieve prototypal inheritance using functions to create objects in JavaScript](#Q19)
2626
20. [Write a polyfill for bind function](#Q20)
27-
21. [Write a function which will create a function bounded to the context like `bind`, but can be overridden when explicit context](#Q21)
27+
21. [Write a function which will create a function bounded to the context like `bind`, but can be overridden when the context is set explicitly](#Q21)
2828
22. [Write a function which helps to achieve multiply(a)(b) and returns product of a and b](#Q22)
2929
23. [Write a code to show the differences between the techniques, currying and partial application](#Q23)
3030
24. [Create a function which takes another function as an argument and makes it eligible for currying or partial application](#Q24)
@@ -673,7 +673,7 @@ This is a simple polyfill for bind without handling corner cases. It does not wo
673673
<br />
674674

675675
#### Q21
676-
### Write a function which will create a function bounded to the context like `bind`, but can be overridden when explicit context
676+
### Write a function which will create a function bounded to the context like `bind`, but can be overridden when the context is set explicitly
677677

678678
- The functionality is similar to `bind` with exception that if there is a context set during the execution it will override
679679

@@ -683,6 +683,8 @@ function softBind(fn, context) {
683683

684684
return function() {
685685
var allArgs = fnArgs.concat(Array.prototype.slice.call(arguments));
686+
687+
// override the context to incoming context if it is not undefined, null or window
686688
var context = (!this || this === window) ? obj : this;
687689
fn.apply(context, allArgs);
688690
};

0 commit comments

Comments
 (0)