kolesoffac

myBind

Mar 26th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Function.prototype.myBind = function(context) {
  2. if (typeof this == "object") {
  3.     for (var prop in this) {
  4.         if (this.hasOwnProperty(prop) && typeof this[prop] == "function") {
  5.             return function() {
  6.                 var args = arguments;
  7.  
  8.                 return this[prop].apply(context, args);
  9.             };
  10.         };
  11.     };
  12. }
Advertisement
Add Comment
Please, Sign In to add comment