mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-07-08 17:34:26 +03:00
23 lines
628 B
JavaScript
23 lines
628 B
JavaScript
/**
|
|
* Bind
|
|
*/
|
|
if ( ! Function.prototype.bind ) {
|
|
Function.prototype.bind = function ( obj ) {
|
|
if ( typeof this !== "function" ) {
|
|
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
|
|
}
|
|
|
|
var slice = [].slice,
|
|
args = slice.call(arguments, 1),
|
|
self = this,
|
|
nop = function () {},
|
|
bound = function () {
|
|
return self.apply( this instanceof nop ? this : ( obj || {} ), args.concat( slice.call( arguments ) ) );
|
|
};
|
|
|
|
nop.prototype = this.prototype;
|
|
bound.prototype = new nop();
|
|
|
|
return bound;
|
|
};
|
|
} |