Preparation Code Preparation HTML (this will be inserted in the <body>
of a valid HTML5 document in standards mode) (useful when testing DOM operations or including libraries) <script src ="https://www.cinsoft.net/mylib099-min.js" > </script >
Setup JS Function .prototype .bindRaynos = function (context ) {
var f = this ;
var curriedArgs = Array .prototype .slice .call (arguments , 2 );
if (curriedArgs.length ) {
return function ( ) {
var allArgs = curriedArgs.slice (0 );
for (var i = 0 , n = arguments .length ; i < n; ++i) {
allArgs.push (arguments [i]);
}
f.apply (context, allArgs);
};
} else {
return createProxy (f, context);
}
};
function createProxy (f, context ) {
return function ( ) {
f.apply (context, arguments );
}
}
var slice = Array .prototype .slice ;
Function .prototype .bindEs5Shim = function bind (that ) {
var target = this ;
if (typeof target != "function" ) {
throw new TypeError ();
}
var args = slice.call (arguments , 1 );
var bound = function ( ) {
if (this instanceof bound) {
var F = function ( ){};
F.prototype = target.prototype ;
var self = new F;
var result = target.apply (
self,
args.concat (slice.call (arguments ))
);
if (Object (result) === result) {
return result;
}
return self;
} else {
return target.apply (
that,
args.concat (slice.call (arguments ))
);
}
};
return bound;
};
var i = { i : 0 };
var f = function ( ) {
this .i ++;
};
var nativelyBound = f.bind (i);
var raynosBound = f.bindRaynos (i);
var es5shimBound = f.bindEs5Shim (i);
Teardown JS