242418 . [ Show the procedure of creating object using a factory function] ( #Q18 )
252519 . [ Achieve prototypal inheritance using functions to create objects in JavaScript] ( #Q19 )
262620 . [ 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 )
282822 . [ Write a function which helps to achieve multiply(a)(b) and returns product of a and b] ( #Q22 )
292923 . [ Write a code to show the differences between the techniques, currying and partial application] ( #Q23 )
303024 . [ 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